Skip to main content

Themes and motion

Theme::neutral returns an owned light or dark theme. The values follow the neutral shadcn theme. Theme lookup is a fixed array access; it does not parse a stylesheet during painting.

auto theme = shadcn::Theme::neutral(shadcn::ColorMode::Dark);
const auto changed = theme.set(shadcn::Role::Primary, {0.8, 0.12, 0.18, 1.0});
if (!changed) {
// The previous colour is unchanged.
}
shadcn::install(app, theme, shadcn::MotionPolicy::Reduced);

The colour setter rejects NaN, infinity and channels outside zero to one. Theme creation uses OKLCH values from the source. The current conversion clips channels outside the sRGB gamut. Browser CSS can use a different gamut mapping method, so colours can differ at the edge of the sRGB gamut.

The reference rem is 16 logical pixels. The neutral radius is 10 pixels. Button dimensions come from their own source variants. The default application font size is 14 logical pixels and install loads the bundled Geist font. Pass a zero or negative final argument to preserve the application font size.

install changes the QApplication style and palette. It must run on the GUI thread. Defer a style replacement until after the current event handler when changing a theme interactively; the gallery demonstrates this with a timer with zero delay.

Full motion uses a 150 ms default timing curve for button, switch and progress transitions. Skeleton uses a pulse lasting two seconds. Reduced motion disables these transitions and the pulse. Hidden skeletons stop animating. The application chooses the motion policy when it calls install.

The neutral theme is the current theme. Chart and sidebar colour roles do not mean that Chart or Sidebar components exist. Arbitrary browser CSS, Tailwind class strings and alternate shadcn profiles are outside the current implementation.