套件
@master/css.react@master/css.react
Integrate Master CSS in React way
Installation
npm i @master/css.reactThe package provides a convenient React provider and context for using @master/css-runtime in React applications.
API Reference
<CSSRuntimeProvider>
The CSSRuntimeProvider will automatically initialize a CSSRuntime instance and manage it according to changes in config or root element.
import CSSRuntimeProvider from '@master/css.react'import config from './master.css'export default function App({ children }) { return ( <CSSRuntimeProvider config={config}> {children} </CSSRuntimeProvider> )}CSSRuntimeProviderProps
import type { Config } from '@master/css'import type { ReactNode } from 'react'export default interface CSSRuntimeProviderProps { children?: ReactNode, config?: Config, root?: Document | ShadowRoot | null // null for Element.shadowRoot}useCSSRuntime()
Access to the CSSRuntime instance.
import { useCSSRuntime } from '@master/css.react'export function YourComponent() { const cssRuntime = useCSSRuntime() // ...}