ThemeBuilder
Builds scoped token previews with hue, scheme, manual color, and export controls.
See it and copy it
Framework example
Choose Astro, React, or Elements to compare native usage against the shared visual output. Each example assumes the framework-level setup is already complete.
Brand theme
View ThemeBuilder code
Framework usage
Switch targets to compare the adapter code. This live preview runs the Astro example. React and Elements use their own behavior APIs; complete the matching framework setup before copying an example.---
import { Button, Label, Slider, Textarea, ThemeBuilder } from '@santi020k/lumen-astro'
---
<ThemeBuilder data-ui-theme-target="#ex-theme-preview">
<header><h3>Brand theme</h3></header>
<div style="display: grid; gap: 0.45rem;">
<Label for="ex-theme-hue">Brand hue</Label>
<Slider
id="ex-theme-hue"
data-ui-theme-brand-hue
min="0"
max="359"
value="264"
/>
<Label for="ex-theme-accent">Accent hue</Label>
<Slider
id="ex-theme-accent"
data-ui-theme-accent-hue
min="0"
max="359"
value="54"
/>
</div>
<div id="ex-theme-preview" style="display: flex; gap: 0.5rem; padding: 0.5rem;">
<span data-ui-swatch style="--ui-swatch:hsl(var(--brand))"></span>
<span data-ui-swatch style="--ui-swatch:hsl(var(--accent))"></span>
</div>
<div style="display: flex; gap: 0.5rem; flex-wrap: wrap;">
<Button data-ui-theme-export>Export CSS</Button>
<Button variant="outline" data-ui-theme-import>Import CSS</Button>
<Button variant="secondary" data-ui-theme-check-contrast>Fix Contrast</Button>
</div>
<Textarea data-ui-theme-output aria-label="Theme CSS" />
</ThemeBuilder>'use client'
import { ThemeBuilder, Card, Button, Label, Slider, Textarea } from '@santi020k/lumen-react'
import { useThemeBuilder } from '@santi020k/lumen-react'
export function CustomThemeBuilder() {
const builder = useThemeBuilder({ defaultHue: 264, defaultScheme: 'dark' })
return (
<ThemeBuilder {...builder.rootProps}>
<div style={builder.previewStyle}>
<Card glass>
<Label htmlFor="theme-brand-hue">Brand hue</Label>
<Slider {...builder.hueProps} id="theme-brand-hue" min={0} max={359} />
<Label htmlFor="theme-accent-hue">Accent hue</Label>
<Slider {...builder.accentHueProps} id="theme-accent-hue" min={0} max={359} />
<div>
<Button {...builder.getSchemeProps('light')}>Light</Button>
<Button {...builder.getSchemeProps('dark')}>Dark</Button>
</div>
<Label htmlFor="theme-output">Generated theme CSS</Label>
<Textarea {...builder.outputProps} aria-label="Generated theme CSS" id="theme-output" readOnly rows={6} />
<Button {...builder.exportButtonProps}>Copy CSS</Button>
</Card>
</div>
</ThemeBuilder>
)
}<script type="module">
import { defineLumenElements } from '@santi020k/lumen-elements/define'
defineLumenElements()
</script>
<lumen-theme-builder data-ui-theme-target="#ex-theme-preview">
<header><h3>Brand theme</h3></header>
<div style="display: grid; gap: 0.45rem;">
<lumen-label for="ex-theme-hue">Brand hue</lumen-label>
<lumen-slider
id="ex-theme-hue"
data-ui-theme-brand-hue
min="0"
max="359"
value="264"></lumen-slider>
<lumen-label for="ex-theme-accent">Accent hue</lumen-label>
<lumen-slider
id="ex-theme-accent"
data-ui-theme-accent-hue
min="0"
max="359"
value="54"></lumen-slider>
</div>
<div id="ex-theme-preview" style="display: flex; gap: 0.5rem; padding: 0.5rem;">
<span data-ui-swatch style="--ui-swatch:hsl(var(--brand))"></span>
<span data-ui-swatch style="--ui-swatch:hsl(var(--accent))"></span>
</div>
<div style="display: flex; gap: 0.5rem; flex-wrap: wrap;">
<lumen-button data-ui-theme-export>Export CSS</lumen-button>
<lumen-button variant="outline" data-ui-theme-import>Import CSS</lumen-button>
<lumen-button variant="secondary" data-ui-theme-check-contrast>Fix Contrast</lumen-button>
</div>
<lumen-textarea data-ui-theme-output aria-label="Theme CSS"></lumen-textarea>
</lumen-theme-builder>Framework differences
React: Connect useThemeBuilder to the root, hue controls, output, and export button. Preview tokens are scoped through previewStyle; the hook reference supplies the same example.
Choose your target
Add this component
Choose the package for your runtime. All adapters share the Lumen stylesheet. Use the matching registry command when you want a local wrapper for that framework.
pnpm add @santi020k/lumen-astropnpm add @santi020k/lumen-astrolumen add ThemeBuilderlumen add ThemeBuilderpnpm add @santi020k/lumen-reactpnpm add @santi020k/lumen-reactlumen add ThemeBuilder --target reactlumen add ThemeBuilder --target reactpnpm add @santi020k/lumen-elementspnpm add @santi020k/lumen-elementslumen add ThemeBuilder --target elementslumen add ThemeBuilder --target elementsGlass
Add the glass prop to apply the shared blur, saturation, border, and highlight tokens. Glass reads best over vivid content, so place the surface above imagery or color.
Brand theme
View ThemeBuilder code
Framework usage
Switch targets to compare the adapter code. This live preview runs the Astro example. React and Elements use their own behavior APIs; complete the matching framework setup before copying an example.---
import { Button, Label, Slider, Textarea, ThemeBuilder } from '@santi020k/lumen-astro'
---
<div class="docs-glass-demo">
<ThemeBuilder data-ui-theme-target="#ex-glass-theme-preview" glass>
<header><h2>Brand theme</h2></header>
<div style="display: grid; gap: 0.45rem;">
<Label for="ex-glass-theme-hue">Brand hue</Label>
<Slider
id="ex-glass-theme-hue"
data-ui-theme-brand-hue
min="0"
max="359"
value="264"
/>
<Label for="ex-glass-theme-accent">Accent hue</Label>
<Slider
id="ex-glass-theme-accent"
data-ui-theme-accent-hue
min="0"
max="359"
value="54"
/>
</div>
<div id="ex-glass-theme-preview" style="display: flex; gap: 0.5rem; padding: 0.5rem;">
<span data-ui-swatch style="--ui-swatch:hsl(var(--brand))"></span>
<span data-ui-swatch style="--ui-swatch:hsl(var(--accent))"></span>
</div>
<div style="display: flex; gap: 0.5rem; flex-wrap: wrap;">
<Button data-ui-theme-export>Export CSS</Button>
<Button variant="outline" data-ui-theme-import>Import CSS</Button>
<Button variant="secondary" data-ui-theme-check-contrast>Fix Contrast</Button>
</div>
<Textarea data-ui-theme-output aria-label="Theme CSS" />
</ThemeBuilder>
</div>'use client'
import { ThemeBuilder, Card, Button, Label, Slider, Textarea } from '@santi020k/lumen-react'
import { useThemeBuilder } from '@santi020k/lumen-react'
export function CustomThemeBuilder() {
const builder = useThemeBuilder({ defaultHue: 264, defaultScheme: 'dark' })
return (
<ThemeBuilder {...builder.rootProps}>
<div style={builder.previewStyle}>
<Card glass>
<Label htmlFor="theme-brand-hue">Brand hue</Label>
<Slider {...builder.hueProps} id="theme-brand-hue" min={0} max={359} />
<Label htmlFor="theme-accent-hue">Accent hue</Label>
<Slider {...builder.accentHueProps} id="theme-accent-hue" min={0} max={359} />
<div>
<Button {...builder.getSchemeProps('light')}>Light</Button>
<Button {...builder.getSchemeProps('dark')}>Dark</Button>
</div>
<Label htmlFor="theme-output">Generated theme CSS</Label>
<Textarea {...builder.outputProps} aria-label="Generated theme CSS" id="theme-output" readOnly rows={6} />
<Button {...builder.exportButtonProps}>Copy CSS</Button>
</Card>
</div>
</ThemeBuilder>
)
}<script type="module">
import { defineLumenElements } from '@santi020k/lumen-elements/define'
defineLumenElements()
</script>
<div class="docs-glass-demo">
<lumen-theme-builder data-ui-theme-target="#ex-glass-theme-preview" glass>
<header><h2>Brand theme</h2></header>
<div style="display: grid; gap: 0.45rem;">
<lumen-label for="ex-glass-theme-hue">Brand hue</lumen-label>
<lumen-slider
id="ex-glass-theme-hue"
data-ui-theme-brand-hue
min="0"
max="359"
value="264"></lumen-slider>
<lumen-label for="ex-glass-theme-accent">Accent hue</lumen-label>
<lumen-slider
id="ex-glass-theme-accent"
data-ui-theme-accent-hue
min="0"
max="359"
value="54"></lumen-slider>
</div>
<div id="ex-glass-theme-preview" style="display: flex; gap: 0.5rem; padding: 0.5rem;">
<span data-ui-swatch style="--ui-swatch:hsl(var(--brand))"></span>
<span data-ui-swatch style="--ui-swatch:hsl(var(--accent))"></span>
</div>
<div style="display: flex; gap: 0.5rem; flex-wrap: wrap;">
<lumen-button data-ui-theme-export>Export CSS</lumen-button>
<lumen-button variant="outline" data-ui-theme-import>Import CSS</lumen-button>
<lumen-button variant="secondary" data-ui-theme-check-contrast>Fix Contrast</lumen-button>
</div>
<lumen-textarea data-ui-theme-output aria-label="Theme CSS"></lumen-textarea>
</lumen-theme-builder>
</div>API reference
Lumen-specific props and runtime attributes for the Astro primitive. Use the framework differences above and the copyable examples for React composition and Elements attributes; the public adapter types define their supported contracts.
| Attribute | Values | Default | Description |
|---|---|---|---|
| glass | boolean | "subtle" | "strong" | false | Applies the tokenized liquid-glass surface treatment with backdrop-filter fallbacks; "subtle" and "strong" adjust the fill intensity. |
| data-ui-theme-target | CSS selector | documentElement | Selects the element that receives generated theme variables. |
| data-ui-theme-brand-hue | range or number input | - | Controls the generated brand hue. |
| data-ui-theme-export | button attribute | - | Exports the current theme in the selected CSS, Figma, or design-token format. |
| class, className | string | "" | Merges custom classes with the generated ui-* root classes. |
| ...native attributes | HTML attributes | - | Forwards standard attributes to the root element unless the component consumes them. |
Runtime events
CustomEvents dispatched by the Astro UIPrimitives runtime for this component.
| Event | Target | Detail | When |
|---|---|---|---|
| ui:theme-change | ThemeBuilder root ([data-ui-theme-builder]) | { hue: number, accentHue: number, mode: 'generated' | 'manual', scheme: 'dark' | 'light', tokens: Record<string, string> } | Fires after ThemeBuilder hue, manual color, mode, or scheme controls update theme tokens on the target element. |
| ui:theme-export | ThemeBuilder root ([data-ui-theme-builder]) | { css?: string, format: 'css' | 'figma' | 'tokens', tokens: Record<string, string> | null, value: string } | Fires after a [data-ui-theme-export] control writes the selected CSS, Figma, or design-token export to the output and clipboard when available. |