LibraryMaterials

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.

Materials

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.

KeyAlready defined before the materials domainNotes
frostedSiteMenuToggle default / --frosted wash in packages/ui/src/navigation/site-menu-toggle.tsx (commit b2db9ed)Translucent paper wash, light bars
inkSiteMenuToggle --ink variant in the same fileLight ink wash, dark bars
embossOriginal HamburgerButton fill in packages/ui/src/navigation/hamburger-button.tsx (commit ded9ec7)3D embossed glass; theme-aware

API

ExportTypeDescription
Material"frosted" | "ink" | "emboss"Derived from MATERIAL_REGISTRY
MATERIAL_REGISTRYrecordLabels, descriptions, token values
MATERIALSMaterial[]Keys of the registry
materialClassName(material?)(material?: Material) => stringziteox-material plus ziteox-material-<name>. Default frosted
getMaterial(material)registry entryLookup helper
isMaterial(value)(value: string) => value is MaterialType guard
MaterialStylescomponentInjects the scoped stylesheet. Render once per tree; extra copies are harmless
MaterialSurfacecomponentdiv 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"].

VariableFrostedInkEmboss (light → dark)
--ziteox-material-bgrgba(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-hoverrgba(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-activergba(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-bordertransparenttransparentrgba(255,255,255,0.72) → rgba(255,255,255,0.1)
--ziteox-material-shadownonenonelayered emboss shadows (theme forks)
--ziteox-material-shadow-hovernonenonelayered emboss hover shadows (theme forks)
--ziteox-material-blurblur(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

DecisionRationale
Registry objectOne place to add a surface; types and CSS follow
Class + variablesAny element can opt in. No Tailwind in @ziteox/ui
Theme-independent frosted/inkThose surfaces stay independent of light/dark theme
Theme-aware embossRecovers the original hamburger .dark forks
Leaf domainmaterials does not import other domains. Other domains may import it