Materials
Composable surface props — not a light/dark mode.
Materials
Domain: materials
Package path: packages/ui/src/materials/
Import: @ziteox/ui or @ziteox/ui/materials
Materials are composable surface props passed to a component (material="frosted"). They are not a light/dark mode — theme stays independent for frosted and ink (same tokens under light and dark). Emboss is the one theme-aware surface: it forks under .dark so the original hamburger 3D fill still reads in both schemes. A component opts in with materialClassName(material) (or a material prop) and renders MaterialStyles once.
The registry exposes surfaces that already existed in Forge: frosted, ink, and emboss. Do not invent new materials in call sites; extend MATERIAL_REGISTRY when a real surface is promoted.
Preview
Each material once (button, nav strip, hamburger). The site theme toggle handles light vs dark — there are no forced light/dark preview panels.
Frosted
Ink
Emboss
Usage
import { MaterialStyles, materialClassName } from "@ziteox/ui";
export function HeaderBar({ scrolled = false }: { scrolled?: boolean }) {
// Pick a surface for the header context — not for light/dark theme.
const material = scrolled ? "ink" : "frosted";
return (
<>
<MaterialStyles />
<header className={materialClassName(material)}>
<a href="/">Ziteox</a>
<button type="button" className={materialClassName(material)}>
Account
</button>
</header>
</>
);
}MaterialSurface is a convenience wrapper when you do not already have an element:
import { MaterialSurface } from "@ziteox/ui";
<MaterialSurface material="ink">Panel</MaterialSurface>Registry
Surfaces live in MATERIAL_REGISTRY. Material is the key union; CSS classes and tokens are generated from the same object. Adding a future material is one registry entry.
| Key | Already defined before the materials domain | Notes |
|---|---|---|
frosted | SiteMenuToggle default / --frosted wash in packages/ui/src/navigation/site-menu-toggle.tsx (commit b2db9ed) | Translucent paper wash, light bars |
ink | SiteMenuToggle --ink variant in the same file | Light ink wash, dark bars |
emboss | Original HamburgerButton fill in packages/ui/src/navigation/hamburger-button.tsx (commit ded9ec7) | 3D embossed glass; theme-aware |
API
| Export | Type | Description |
|---|---|---|
Material | "frosted" | "ink" | "emboss" | Derived from MATERIAL_REGISTRY |
MATERIAL_REGISTRY | record | Labels, descriptions, token values |
MATERIALS | Material[] | Keys of the registry |
materialClassName(material?) | (material?: Material) => string | ziteox-material plus ziteox-material-<name>. Default frosted |
getMaterial(material) | registry entry | Lookup helper |
isMaterial(value) | (value: string) => value is Material | Type guard |
MaterialStyles | component | Injects the scoped stylesheet. Render once per tree; extra copies are harmless |
MaterialSurface | component | div with the material class and stylesheet |
MATERIAL_BASE_CLASS | "ziteox-material" | Shared base class |
Tokens
Painted on .ziteox-material. Override any of these on the element or an ancestor. Frosted and ink values do not fork under .dark. Emboss sets dark tokens under .dark / [data-theme="dark"].
| Variable | Frosted | Ink | Emboss (light → dark) |
|---|---|---|---|
--ziteox-material-bg | rgba(255,255,255,0.1) | rgba(7,9,10,0.06) | rgba(255,255,255,0.45) → rgba(255,255,255,0.12) |
--ziteox-material-bg-hover | rgba(255,255,255,0.2) | rgba(7,9,10,0.12) | rgba(255,255,255,0.58) → rgba(255,255,255,0.18) |
--ziteox-material-bg-active | rgba(255,255,255,0.2) | rgba(7,9,10,0.12) | same as hover |
--ziteox-material-ink | #f1f0eb | #07090a | #18181b → #fff |
--ziteox-material-bar | #f1f0eb | #07090a | #18181b → #fff |
--ziteox-material-border | transparent | transparent | rgba(255,255,255,0.72) → rgba(255,255,255,0.1) |
--ziteox-material-shadow | none | none | layered emboss shadows (theme forks) |
--ziteox-material-shadow-hover | none | none | layered emboss hover shadows (theme forks) |
--ziteox-material-blur | blur(12px) | blur(12px) | blur(12px) saturate(1.25) |
Hover uses the hover background and shadow. Active uses the active background. Press scale stays on the control that wants it (menu toggles), not on every surface.
Choose frosted for a dark header context and ink for a paper header — that is composition, not theme mode. Choose emboss when you want the original 3D hamburger fill that tracks the site theme.
Architecture notes
| Decision | Rationale |
|---|---|
| Registry object | One place to add a surface; types and CSS follow |
| Class + variables | Any element can opt in. No Tailwind in @ziteox/ui |
| Theme-independent frosted/ink | Those surfaces stay independent of light/dark theme |
| Theme-aware emboss | Recovers the original hamburger .dark forks |
| Leaf domain | materials does not import other domains. Other domains may import it |