Package
React
A React integration for Master CSS
Installation
npm i @master/css.react
The 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() // ...}