Theming

ThemeScope

Applies the provider’s tokens to a DOM subtree.

tsx
import { ThemeScope } from '@precursor/theme';

Example

This part of the page uses monospace.

tsx
import { Suspense } from 'react';
import { Globals, ThemeProvider, ThemeScope } from '@precursor/theme';
import Text from '@precursor/text';
export default function Example() {
    return (
        <Suspense fallback={<p>Loading theme…</p>}>
            <ThemeProvider
                selection={{ colorMode: 'light', typography: 'monospace' }}
            >
                <ThemeScope>
                    <Globals />
                    <Text>This part of the page uses monospace.</Text>
                </ThemeScope>
            </ThemeProvider>
        </Suspense>
    );
}

Props

ThemeScope props
PropTypeDefaultNotes
childrenRequiredReactNode——