Skip to content

Get started

Theming

Adapt every Vitrum component and custom `<GlassSurface>` to your brand with `<VitrumProvider>`, 5 curated glass presets, `createGlassTheme()`, and `--vitrum-*` CSS variables.

Markdown
glass-theme-presets.tsx

Frost

blur 5px · refract 1× · fluid

tint 65%spec 1×rim 1×

Built-in presets

  • `frost` (default) — balanced neutral refractive glass for light and dark interfaces.
  • `obsidian` — deep high-contrast dark smoked glass with crisp specular rims.
  • `aurora` — iridescent cool-cyan/violet refractive tint with fluid springs.
  • `amber` — warm golden-hour architectural glass with gentle motion.
  • `crystal` — ultra-clear high-refraction optical glass with minimal frost.

Wrapping your app

Wrap your root layout (or any subtree) in <VitrumProvider>. Standalone components used outside <VitrumProvider> keep their exact v1.0 defaults without needing any provider.

layout.tsx
import '@vitrumui/react/styles.css'
import { VitrumProvider } from '@vitrumui/react/theme'

export function Providers({ children }: { children: React.ReactNode }) {
  return (
    <VitrumProvider theme="aurora" colorScheme="system">
      {children}
    </VitrumProvider>
  )
}

Custom brand themes

theme.ts
import { createGlassTheme, VitrumProvider } from '@vitrumui/react/theme'

const brandGlass = createGlassTheme(
  {
    name: 'brand-indigo',
    tint: '#e0e7ff',
    tintOpacity: 0.55,
    blur: 7,
    refraction: 1.2,
    specular: 1.3,
    motionPreset: 'snappy',
    dark: { tint: '#1e1b4b', tintOpacity: 0.7 },
  },
  'frost',
)

<VitrumProvider theme={brandGlass}>{children}</VitrumProvider>

Reading & switching themes

switcher.tsx
import { useVitrumTheme, VITRUM_THEME_NAMES } from '@vitrumui/react/theme'

export function ThemeSwitcher() {
  const { theme, resolvedColorScheme, setTheme, setColorScheme } = useVitrumTheme()
  return (
    <button onClick={() => setTheme(theme.name === 'frost' ? 'obsidian' : 'frost')}>
      Active: {theme.name} ({resolvedColorScheme})
    </button>
  )
}

CSS custom properties

@vitrumui/react/styles.css defines :root defaults and <VitrumProvider> scopes --vitrum-tint, --vitrum-tint-opacity, --vitrum-blur, --vitrum-refraction, --vitrum-specular, --vitrum-rim-light, --vitrum-shadow-strength, --vitrum-border-opacity, --vitrum-radius-scale, and --vitrum-motion onto its subtree.

API reference

PropTypeDefault
theme

Built-in preset name or custom theme created with createGlassTheme().

'frost' | 'obsidian' | 'aurora' | 'amber' | 'crystal' | VitrumTheme'frost'
colorScheme

Synchronises dark-mode glass optics automatically with system / .dark preference.

'system' | 'light' | 'dark''system'
applyToRoot

Mirrors active --vitrum-* variables onto document.documentElement as well.

booleanfalse
useVitrumTheme()

Hook to inspect or switch the active glass theme and colour scheme.

{ theme, resolvedColorScheme, setTheme, setColorScheme, cssVars }—