Skip to content

Theming ​

uni-ui.css reads data-theme on <html>: light or dark forces a scheme, and no attribute follows the OS setting. ColorScheme sets the attribute from an Rx:

scala
import wvlet.uni.dom.all.*
import wvlet.uni.dom.all.given
import wvlet.uni.rx.Rx
import wvlet.uni.ui.*
import scala.language.implicitConversions

val scheme = Storage.local("app.colorScheme", ColorScheme.System)
ColorScheme.bind(scheme)
scheme := ColorScheme.Dark

To change colors, set the variables after uni-ui.css:

css
:root {
  --uni-accent: #6d28d9;
  --uni-accent-2: #8b5cf6;
  --uni-radius: 4px;
}
VariableUsed for
--uni-canvas, --uni-surface, --uni-panel, --uni-raisedBackgrounds, from the window down to raised controls
--uni-fg, --uni-muted, --uni-faintText, from primary to placeholder
--uni-line, --uni-hoverBorders and hover fills
--uni-accent, --uni-accent-2, --uni-accent-fg, --uni-accent-softThe primary button gradient, its text, and focus rings
--uni-danger, --uni-danger-softDanger buttons and invalid fields
--uni-success, --uni-success-softSuccess toasts
--uni-overlay-shadow, --uni-backdropOverlay shadows and the dialog backdrop
--uni-tooltip-bg, --uni-tooltip-fgTooltip colors
--uni-z-popover, --uni-z-dialog, --uni-z-toastStacking order of popovers and menus, dialogs, and toasts and tooltips
--uni-radius-sm, --uni-radius, --uni-radius-lgCorner radii
--uni-font-sans, --uni-font-mono, --uni-font-size, --uni-font-size-smFonts

Every rule in uni-ui.css sits in the uni cascade layer, so your own CSS overrides it without !important (see Loading uni-ui.css). To style one part of a component, select its data-slot and data-state attributes.

Released under the Apache 2.0 License.