Custom style

A style is a plain object: every component's classes, typed by ScStyle. To have your own look, start from one of ours: copy it into your app, give it your name, then change what you want. The components read it like any other style.

1. Copy a style

Pick the style closest to what you want and copy its folder from the repository (packages/styles/nova/src for nova) into your app. One file per component, plus the file that puts them together:

src/app/my-style/
src/app/my-style/├── accordion.ts├── button.ts├── card.ts├── frame.ts├── …            # one file per component├── nova.ts      # puts them together└── index.ts

2. Name it

Rename the file that puts the parts together, and its export — the name is yours:

my-style/my-style.ts (was nova.ts)
import type { ScStyle } from '@semantic-components/styles';import { accordion } from './accordion';// … the other imports, unchanged
export const myStyle: ScStyle = {  accordion,  // … the other keys, unchanged};
my-style/index.ts
export * from './my-style';

3. Use it

Give it to provideSemanticComponents when the app starts:

app.config.ts
import { provideSemanticComponents } from '@semantic-components/ui';import { myStyle } from './my-style';
export const appConfig: ApplicationConfig = {  providers: [provideSemanticComponents({ preset: { style: myStyle } })],};

Keep @semantic-components/styles installed: your files import its types (import type, nothing else), and class-variance-authority, which you already have with the ui library. Tailwind scans your app's files, so the style's classes need no @source — remove the one for the style you used before.

4. Change it

Each file holds one component's classes, in Tailwind. Change a file, and every component that reads it follows — the cards and every framed box, for instance, take their corners, ring and shadow from frame.ts:

my-style/frame.ts
// The card's frame: its corners, ring and shadow.export const frame = 'rounded-2xl shadow-sm ring-1 ring-foreground/10';
// A small box's frame (scFrame size="sm": a row, an icon's box).export const frameSm = 'rounded-md ring-1 ring-border';

Some keys are variant functions (cva, as in button.ts): change the classes of a variant, keep its name — the components ask for it by name. The ScStyle type keeps you whole: a key missing or of the wrong shape doesn't compile.

Only a few changes?

Then no copy: spread one of ours and replace the keys you change. It keeps our updates for the rest — and its @source line, since its classes still come from the package.

my-style.ts
import type { ScStyle } from '@semantic-components/styles';import { nova } from '@semantic-components/styles/nova';
export const myStyle: ScStyle = {  ...nova,  frame: 'rounded-2xl shadow-sm ring-1 ring-foreground/10',};

Good to know

  • A style is set when the app starts: switching it means reloading.
  • A copied style is yours: it won't get the changes we make to ours. When you update the library, compare your files with the new ones of the style you started from — a new component brings a new key, which the type will ask for.
  • The theme isn't in a style: it is every CSS variable shadcn gives — colours, radius, fonts, charts, sidebar (--primary, --radius, --font-sans…) — in your styles.css. A style says how things are drawn; the theme, with which values.