Once UI Handbook
Beginner Guides
What is Once UI?
Install & config
Page skeleton
Your first page
Build And Launch
How to launch a portfolio site that actually gets you hired
How to build a documentation site with MDX and Next.js
How to ship a landing page and dashboard with authentication in Next.js
How to launch a social app with Next.js and Supabase
Vibe Coding
Introduction to vibe coding
Set up your local dev environment
Essential tools for vibe coding
Build your first Once UI app
Common Patterns
Hero section
Static panel
Form layout
Highlighted card
Responsive stacking
Decoration layers
Dialog & modal
Toast & feedback
Tables & lists
Loading states
App shell navigation
Dashboard & charts
Chat & messaging
Auth & verification
Settings & split panels
Data filters & toolbar
Command palette
Pricing & plans
Accordion & FAQ
Media & uploads
Empty & error states
SEO, Open Graph, and structured data
Documentation code blocks with live preview
Carousels, galleries, and before/after comparisons
Date pickers and scheduling
Context menus and dropdown actions
Tags, chips, and multi-value inputs
Roadmap & kanban
Form inputs & controls
Progress, status & badges
Scrolling & feeds
Profile, avatars & identity
Social proof & logo clouds
Masonry & media grids
Table pagination, search & bulk selection
Banners & announcements
Footer layouts
Onboarding & first run
Waitlist & coming soon
Design Tips
Color & surfaces
Harness overview
Row, Column & Grid
Spacing & rhythm
Icons & buttons
Reveal & motion
Theme tokens, FOUC-free init, and runtime style controls
Tooltips and hover cards
Block updates
Block updates changelog
Agent Resources
Column, not Flex
Semantics over CSS
Typography scale
Common gotchas
Block anchors
Validate generated code
Pro block registry
Match task bundles
TrademarkTrademark
Ctrl k
Search...
Sign up
Once UI Handbook
Beginner Guides
What is Once UI?
Install & config
Page skeleton
Your first page
Build And Launch
How to launch a portfolio site that actually gets you hired
How to build a documentation site with MDX and Next.js
How to ship a landing page and dashboard with authentication in Next.js
How to launch a social app with Next.js and Supabase
Vibe Coding
Introduction to vibe coding
Set up your local dev environment
Essential tools for vibe coding
Build your first Once UI app
Common Patterns
Hero section
Static panel
Form layout
Highlighted card
Responsive stacking
Decoration layers
Dialog & modal
Toast & feedback
Tables & lists
Loading states
App shell navigation
Dashboard & charts
Chat & messaging
Auth & verification
Settings & split panels
Data filters & toolbar
Command palette
Pricing & plans
Accordion & FAQ
Media & uploads
Empty & error states
SEO, Open Graph, and structured data
Documentation code blocks with live preview
Carousels, galleries, and before/after comparisons
Date pickers and scheduling
Context menus and dropdown actions
Tags, chips, and multi-value inputs
Roadmap & kanban
Form inputs & controls
Progress, status & badges
Scrolling & feeds
Profile, avatars & identity
Social proof & logo clouds
Masonry & media grids
Table pagination, search & bulk selection
Banners & announcements
Footer layouts
Onboarding & first run
Waitlist & coming soon
Design Tips
Color & surfaces
Harness overview
Row, Column & Grid
Spacing & rhythm
Icons & buttons
Reveal & motion
Theme tokens, FOUC-free init, and runtime style controls
Tooltips and hover cards
Block updates
Block updates changelog
Agent Resources
Column, not Flex
Semantics over CSS
Typography scale
Common gotchas
Block anchors
Validate generated code
Pro block registry
Match task bundles
TrademarkTrademark
Once UIDocumentationBlog
© Once UI. All rights reserved.
Built with Aveiro
Design tips

Theme tokens, FOUC-free init, and runtime style controls

ThemeInit, ThemeProvider, data-* attributes, and DataThemeProvider for charts.
Updated 19d ago
Reveal & motion
Tooltips and hover cards
6 min · Design
ThemeInit prevents FOUC, ThemeProvider persists style knobs to localStorage, and data-* attributes on html drive every token in theme.scss.

How theming works

Once UI does not rely on CSS-in-JS for theme switching. Instead:
  • ThemeInit — blocking inline script in the document head sets data-theme, data-brand, data-accent, etc. before first paint
  • ThemeProvider — client context that reads/writes the same data-* keys to localStorage
  • tokens/theme.scss — selectors like [data-theme="dark"][data-brand="blue"] map to CSS variables
This means zero flash of wrong theme and no prop-drilling for colors.

ThemeInit in your root layout

Render ThemeInit inside html before body. Pass defaults that match your brand — users can override via localStorage or a settings panel. Priority order: localStorage → config defaults → system preference (for theme: "system").

ThemeProvider for interactive apps

Wrap client subtrees with ThemeProvider. Use useTheme() for light/dark/system and useStyle() for brand, accent, border style, surface, scaling, and more. Default props to match ThemeInit: theme="system", brand="blue", accent="indigo". setStyle({ border: "conservative", scaling: "105" }) updates both the DOM attribute and localStorage so refreshes keep the choice.

Style dimensions at a glance

Attribute
Options
Effect
`data-theme`light, dark, systemColor scheme
`data-brand` / `data-accent`scheme tokensPrimary + highlight hues
`data-neutral`sand, gray, slateGray ramp
`data-border`rounded, playful, conservativeCorner radius scale
`data-surface`filled, translucentPanel opacity
`data-scaling`90–110Global size multiplier
`data-viz-style`categorical, divergent, sequentialChart color ramps
color-and-surfaces covers which token to pick — this page covers how they get applied at runtime.

Charts follow data theme

Wrap dashboard routes with DataThemeProvider and read useDataTheme() inside chart pages. LineChart and siblings pick categorical vs sequential palettes from automatically.
config.theme = "system"
config.brand = "blue"
config.accent = "indigo"
config.neutral = "gray"
config.solid = "contrast"
config.solid-style = "flat"
config.border = "playful"
config.surface = "filled"
config.transition = "all"
config.scaling = "100"
config.viz-style = "categorical"
data-viz-style
Build a chart section with Column + Heading + LineChart — pass data, xKey, yKey, and height. Toggle viz-style in your settings panel to verify chart colors track the global data theme.

Built-in UI switchers

Core ships ThemeSwitcher and StylePanel for full settings surfaces. Drop them in a header dropdown or a /settings/appearance route — both call the same setStyle API under the hood.
For minimal headers, a three-option SegmentedControl (light / system / dark) wired to setTheme is enough.

Write this / not this

✅ Once UI way
❌ Common mistake
ThemeInit in document headClient-only theme after hydration flash
`data-brand` tokensHard-coded hex in components
`setStyle` for user prefsInline `style={{ color: … }}` overrides
`DataThemeProvider` on chart routesCharts with fixed color arrays

Check yourself

  • ThemeInit renders before body content
  • Defaults in ThemeInit match ThemeProvider props
  • Settings UI updates persist across refresh
  • Chart pages sit inside DataThemeProvider

Related

→ Color & surfaces → Dashboard & charts → Settings & split panels → Full reference: docs.once-ui.com — ThemeProvider