Appearance
createAppearance and <Appearance>: keep the .dark class, data-theme, data-palette, data-density and data-radius on <html> in sync with a color scheme (system follows prefers-color-scheme live, or light or dark), a theme, a palette, a density (default or compact) and a corner radius (none, sm, md, lg or full), optionally saved between visits. Works in a static file:// page.
Example
appearance-demo.tsxCopy code
Installation
Copy code
Brings alongnarrow
Usage
ImportCopy code
Create one appearance per app, call apply() before the first render, and wrap the app in <Appearance>.
API reference
Appearance
| Prop | Type | Default |
|---|---|---|
appearancerequired | AppearanceState<Theme, Palette> | – |
children | ReactNode | – |
Other exports
createAppearancedefaultPalettesdefaultThemesdensitiesradiiuseConnectedAppearancetype Appearancetype AppearanceOptionstype Densitytype Radiustype AppearancePropstype AppearanceStateAccessibility
- Follows prefers-color-scheme until the person chooses, and keeps that choice in storage you pass.
- Writes data-color-scheme so a server-rendered page can honour an explicit light choice with no flash.
Agent actions
Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.