Get started

Theming

Colour with CSS variables, tune the material with one config object.

Markdown

Every colour the shader uses is read from CSS custom properties on the element, so presets, themes and your own colours all go through CSS. Light and dark follow prefers-color-scheme, or data-theme on <html>.

Tokens

NameTypeDefault
--clay-color

The element's own clay. Set by color.

color —
--clay-surface

Grooves and boxes of controls.

color #dde5ed
--clay-knob

Knobs, balls and the segmented bead.

color #f6f9fb
--clay-popup

Select lists, menus, popovers, dialogs and plain toasts.

color #eef3f7
--clay-success / --clay-danger

Roll's bead when it lands or fails, success and error toasts, an invalid field's rim.

color —
--clay-danger-text

Danger menu items and error messages written on clay.

color —
--clay-teal … --clay-ink

The ten presets color accepts.

color —
--clay-text / --clay-text-soft

Text on light clay.

color —
--clay-ring

Focus outlines.

color —
--clay-spring

A linear() spring for CSS motion: popups, labels, icons.

easing —

Each element wears its own --clay-color, so a coloured card doesn't recolour the controls inside it. The other tokens come from where a part sits: set --clay-surface or --clay-text on a dark card and the grooves and labels of the controls in it follow.

Your own colour

index.html
<clay-button color="oklch(0.72 0.12 30)">
  <ui-button><button>Coral</button></ui-button>
</clay-button>

The material

CLAY holds the shader's material and light: pillow, steepness, wrap, subsurface, sheen, grain, shadows and the light direction. Change it at startup, or tune it live in the Playground and paste the values it copies.

main.ts
import { CLAY, getClayEngine } from "claymorph-ui"

Object.assign(CLAY, { pillow: 0.7, grain: 0.08 })
getClayEngine()?.invalidateAll()