Get started
Theming
Colour with CSS variables, tune the material with one config object.
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
| Name | Type | Default |
|---|---|---|
--clay-colorThe element's own clay. Set by |
color |
— |
--clay-surfaceGrooves and boxes of controls. |
color |
#dde5ed |
--clay-knobKnobs, balls and the segmented bead. |
color |
#f6f9fb |
--clay-popupSelect lists, menus, popovers, dialogs and plain toasts. |
color |
#eef3f7 |
--clay-success / --clay-dangerRoll's bead when it lands or fails, success and error toasts, an invalid field's rim. |
color |
— |
--clay-danger-textDanger menu items and error messages written on clay. |
color |
— |
--clay-teal … --clay-inkThe ten presets |
color |
— |
--clay-text / --clay-text-softText on light clay. |
color |
— |
--clay-ringFocus outlines. |
color |
— |
--clay-springA |
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
<clay-button color="oklch(0.72 0.12 30)">
<ui-button><button>Coral</button></ui-button>
</clay-button>
<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.
import { CLAY, getClayEngine } from "claymorph-ui"
Object.assign(CLAY, { pillow: 0.7, grain: 0.08 })
getClayEngine()?.invalidateAll()
import { CLAY, getClayEngine } from "claymorph-ui"
Object.assign(CLAY, { pillow: 0.7, grain: 0.08 })
getClayEngine()?.invalidateAll()