Skip to content

Theme system

Give Shavin one brand colour and it themes the whole product. Everything else (grays, radius, density, fonts) has a sensible default you can change with one prop or a preset.

Start with your brand colour

import { ThemeProvider } from "@shavin/ui";

export default function App() {
  return (
    <ThemeProvider brandColor="#0F766E">
      <MainLayout />
    </ThemeProvider>
  );
}

From that one value Shavin derives, for light and dark mode: the hover colour, the text colour on brand fills, the brand text, link and focus colours (adjusted to about 4.6:1 contrast on every surface), and soft tints for selected and highlighted states. Grays come from one of five neutral presets rather than from your colour.

Light mode
BrandHover
Link and brand text · 5.5:1Focus ring
Dark mode
BrandHover
Link and brand text · 5.2:1Focus ring

Text, link and focus colours are darkened or lightened until they reach about 4.6:1 on the page.

Try a brand colour. Every value below is derived from it, with the contrast it reaches on the page.

Change the rest

<ThemeProvider
  brandColor="grass"        // a preset name or any hex
  grayColor="zinc"           // zinc, slate, gray, neutral or stone
  radius="large"             // none, small, medium, large, full
  scaling="95%"              // 90% to 110%; 95% suits dense apps
  panelBackground="translucent"
>

Set the colours through ThemeProvider rather than overriding --brand in CSS: the provider recomputes the hover, contrast, link and focus tokens, and its values take precedence over your own :root rules.

Theme presets

16 curated themes

Skip manual property declarations — pass a single theme name to load a curated brand config including brand, neutrals, radius, density, panel style, and a display/body font pairing. Add individual props alongside to override any setting.

import { ThemeProvider } from "@shavin/ui";

<ThemeProvider theme="Editorial">
  <App />
</ThemeProvider>
dark
dark
dark
dark
dark
dark
dark
dark
dark
light
light
light
light
light
light
light

Font pairings load dynamically from Google Fonts. Tweak any control in the Configurator (top-right) and the preset auto-switches to “Custom”.

Scoped themes

<ScopedThemeProvider>

Wrap any subtree in <ScopedThemeProvider> to isolate theme settings (brand color, gray scale, radius, scaling, appearance) without altering the global application :root.

import { ScopedThemeProvider, Button, Card, Badge, Text } from "@shavin/ui";

export function ScopedIsland() {
  return (
    <ScopedThemeProvider
      brandColor="grass"
      grayColor="zinc"
      radius="large"
      appearance="dark"
      className="p-6 rounded-[var(--radius-panel)] border border-hairline bg-canvas min-h-[320px]"
    >
      <Card padding="md" className="flex flex-col gap-3">
        <Badge tone="brand">Scoped theme</Badge>
        <Text weight="medium">Tokens inside this container are fully isolated.</Text>
        <Button variant="solid" tone="brand">Brand Action</Button>
      </Card>
    </ScopedThemeProvider>
  );
}

What Shavin works out for you

From your one brand colour, Shavin derives readable text, links, focus rings and hover fills for light and dark mode. Brand contrast shows how, and surface scoping covers dark bands and text on photos.

Configure Theme
Theme
Brand Color
Custom
Gray Family
Appearance
Radius
Scaling
Panel Style
Heading Font
Body Font