2.0 alpha
These docs describe 2.0. Install it with @once-ui-system/core@alpha.
On 1.8.x? Read the 1.x docs
TrademarkTrademarkDocs
Ctrl k
Search docs...
Components

StylePanel

Updated: May 11, 2025
View on GitHub
StylePanel is a component to set global styling options. It writes to the root HTML element’s data-* attributes to affect global styles in real time. It doesn't persist settings by default. Choose between light/dark mode and various border radius presets. Change brand, accent, and neutral palettes. These affect buttons, links, surfaces, and other themed elements. Adjust the visual language of interactive elements (e.g., plastic vs flat button styling). Modify surface behavior (translucent vs filled), scale intensity, and transition timing. Applies the following data-* attributes to the <html> element:
  • data-border
  • data-brand
  • data-accent
  • data-neutral
  • data-solid
  • data-solid-style
  • data-theme
  • data-transition
  • data-scaling
  • data-surface
  • data-body-size
  • data-body-line-height
StylePanel is a plain composition of its own parts. When you need a different arrangement, or only some of the sections, drop it and compose the pieces inside StylePanel.Root: Rows: Theme, Shape, Brand, Accent, Neutral, Solid, Effect, Surface, Scaling, Transition, DataStyle, BodySize, BodyLineHeight. Groups: Page, Color, SolidStyle, BodyText, Advanced. Only DataStyle needs a DataThemeProvider in the tree, so a panel without it has no such requirement. Every row takes a label, and every group a title and description. Pass a node to replace the default, or false to drop it — which is how you localise the panel: To keep the default arrangement and hide parts of it, use visibility. Omitted keys stay visible; section: false hides a whole group. bodyText is the exception: it is opt-in, so pass { bodyText: { section: true } } to show it. By default the panel reads and writes ThemeProvider, which persists to localStorage. Pass value and onChange to take that over — the panel then writes nothing to the providers or to storage, and you decide what a change means: changed holds only the keys this interaction touched, which is what you want to send to a server; next is the whole state. To keep the panel bound to ThemeProvider but change where choices are stored, set persistence on the provider instead — see ThemeProvider.
Prop
Type
Default
visibility
Which sections and rows to show.
StylePanelVisibility
value
Take ownership of the state. The panel then writes nothing to the providers or to storage.
StylePanelRootProps["value"]
onChange
Called with the whole state and just the keys that changed — the latter being what you send to a server.
StylePanelRootProps["onChange"]
…and every FlexProps propinherited
className
string
style
React.CSSProperties
Edit this page on GitHub
TrademarkTrademark
Built with curiosity by Lorant One and the Design Engineers Club