Theming

Three things decide how your app looks — together, its preset: the style (how the components are drawn), the theme (every CSS variable shadcn gives: colours, radius, fonts, charts, sidebar) and the mode (light, dark or the system's). The user's theme and mode are kept from one visit to the next.

The preset

A style (nova, vega, maia, lyra, mira, luma, sera, rhea) is the components' classes — shadcn's eight styles: corners, spacing, borders, the way a button or a field is built; fixed when the app starts. The theme is your CSS: all of shadcn's variables, which every style reads, and a named theme if you have several. The mode is light or dark: the first one, until the user picks.

import { provideSemanticComponents } from '@semantic-components/ui';import { lyra } from '@semantic-components/styles/lyra';
export const appConfig = {  providers: [    provideSemanticComponents({      preset: { style: lyra, theme: 'rose', mode: 'dark' },    }),  ],};

See Styles for the eight, side by side.

Theme

The same variables as shadcn/ui, so a theme from its generator or from tweakcn carries over — all of them, not only the colours: colours in OKLCH on :root, their dark values on .dark, the corners from one --radius, the fonts from --font-sans and --font-heading. Charts read --chart-1 to --chart-5; the sidebar its --sidebar-… variables.

:root {  --radius: 0.625rem;  --background: oklch(1 0 0);  --foreground: oklch(0.145 0 0);  --primary: oklch(0.205 0 0);  --primary-foreground: oklch(0.985 0 0);  /* … card, popover, secondary, muted, accent, destructive, border, input, ring */  --chart-1: oklch(0.646 0.222 41.116);}
.dark {  --background: oklch(0.145 0 0);  --foreground: oklch(0.985 0 0);  --primary: oklch(0.922 0 0);  /* … */}

Several themes: give each a name, write its variables (any of them, the radius and the fonts too) under [data-theme], and set it — the preset's theme at first, ScPresetManager's setTheme('rose') when the user picks ('default': none).

[data-theme='rose'] {  --primary: oklch(0.645 0.246 16.439);  --ring: oklch(0.645 0.246 16.439);  --radius: 1rem;}

Mode

ScPresetManager holds the mode — light, dark or system — and puts the dark class on the page's root when it is dark. There is no toggle part: any control of yours calls it, so a button, a switch or a menu with System in it all work.

The mode is that class, nothing more: no color-scheme is written on the page. The manager always runs — provideSemanticComponents() starts it, so the mode applies on every page — and an app with one mode only says it in the config (preset: { mode: 'light' }).

import { ScPresetManager } from '@semantic-components/ui';
export class ModeButton {  protected readonly preset = inject(ScPresetManager);}
// <button scButton variant="outline" size="icon" (click)="preset.toggleMode()">//   @if (preset.isDark()) { <svg siSunIcon></svg> } @else { <svg siMoonIcon></svg> }//   <span class="sr-only">Toggle the mode</span>// </button>// …or preset.setMode('system')

One click goes between light and dark; a menu keeps the way back to the system's, which a single button loses.

One click

Current: light
import { Component, ViewEncapsulation, inject } from '@angular/core';import { ScButton, ScPresetManager } from '@semantic-components/ui';import { SiMoonIcon, SiSunIcon } from '@semantic-icons/lucide-icons';
/** One click between light and dark: any button calling toggleMode(); its name follows the state. */@Component({  selector: 'app-theme-toggle-demo',  imports: [ScButton, SiSunIcon, SiMoonIcon],  template: `    <div class="flex items-center gap-4">

Light, dark or system

import { Component, ViewEncapsulation, inject } from '@angular/core';import {  ScButton,  ScMenu,  ScMenuContent,  ScMenuItemIndicator,  ScMenuPortal,  ScMenuProvider,  ScMenuRadioGroup,  ScMenuRadioItem,

The user's mode and theme are kept in cookies (sc-mode, sc-theme, copied to localStorage), so a page rendered on the server is drawn right from the first paint. System is the browser's: a small script the server puts in the page's head applies it before the first paint. Another app on the same host shares those cookies: name yours with storageKeys in provideSemanticComponents().