Theme
Applies light or dark mode, and a color palette, to the part of the page inside it.
Usage
import { Theme } from '@leverui/components';
<Theme appearance="dark">
<div />
</Theme>
Examples
Nested
The theme can be nested to apply different appearances to different parts of the tree. This is useful for applying a global appearance and then overriding some parts of it.
Good to know: We use native CSS selectors to achieve this.
Portalled
Use the asChild prop to force the appearance of portalled elements like the popover and modal content.
Lanternwright notes
The Lanternwright Chronicles is a fantasy novel series about an apprentice lamplighter in a city that rearranges itself every night.
Page Specific Color Mode
Wrap the whole page in Theme.
import type { ParentProps } from 'solid-js';
import { Theme } from '@leverui/components';
export function ForcedColorMode(props: ParentProps) {
return <Theme appearance="dark">{props.children}</Theme>;
}
Guides
Scoped appearance
Finish the stylesheet setup first. Theme applies
light or dark mode only to the elements inside it. By default it also gives
that section the theme's text and background colors.
Leave out appearance to use the surrounding mode. Set hasBackground={false}
to leave the background as it is. Also takes native HTML attributes, class,
style, and a named colorPalette.
Portalled content
Mount portal content inside the Theme, or give it the same theme values
where it renders. Theme changes colors only, not what its children mean to
browsers and screen readers.
Customize with CSS
Add a class to set public --leverui-* variables for that section only. See
the CSS theme guide. Changing a palette scale color on the
nested element does not recompute a background color it inherited. Set
--leverui-colors-bg directly when you need to.
<Theme appearance="dark" class="preview-panel">
<Text>Dark preview</Text>
</Theme>
.preview-panel {
padding: var(--leverui-spacing-4);
}