FLOWDocs

Theming

Light, dark, और custom palettes।

Flow UI में कोई theming engine नहीं है — हर theme बस :root या scoped parent पर set किया गया CSS variable set है। एक class swap से theme toggle हो जाता है।

Light और dark

दोनों out of the box ship होते हैं। Subtree switch करने के लिए <html> (या किसी भी parent) पर .dark जोड़ें या हटाएं।

function ThemeToggle() {
  return (
    <button
      onClick={() => document.documentElement.classList.toggle("dark")}
    >
      Toggle theme
    </button>
  );
}

System-respecting default के लिए boot पर एक बार prefers-color-scheme match करें:

if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
  document.documentElement.classList.add("dark");
}

Custom palette

Flow imports के बाद अपने app की CSS में tokens override करें। Downstream का कोई भी component इन्हें automatically pick कर लेगा।

@import "@flow-industries/ui/styles/tokens.css";
@import "@flow-industries/ui/styles/base.css";
@import "@flow-industries/ui/styles/fonts.css";

:root {
  --brand: oklch(0.7 0.2 40);     /* orange brand */
  --brand-foreground: oklch(0.15 0 0);
  --radius: 0.25rem;              /* sharper corners */
}

.dark {
  --background: oklch(0.15 0 0);
  --foreground: oklch(0.95 0 0);
  --muted: oklch(0.22 0 0);
}

हर override-able variable के लिए Tokens देखें।

OKLch क्यों

रंग hex या HSL के बजाय OKLch में define किए गए हैं क्योंकि:

  • Perceptual uniformity — equal numeric steps equal brightness steps जैसे महसूस होते हैं।
  • Meaningful interpolation — दो OKLch रंगों के बीच color-mix() मटमैले greys से नहीं गुज़रता।
  • Wide-gamut ready — modern displays पर P3 और Rec2020 के लिए cleanly map होता है।

Hex से convert करने के लिए: oklch.com या कोई भी culori-based tool use करें।

Scoped themes

चूंकि हर token एक साधारण CSS variable है, आप किसी भी subtree के लिए palette को scope कर सकते हैं:

<div className="brand-purple">
  <Button variant="brand">Purple brand</Button>
</div>
.brand-purple {
  --brand: oklch(0.65 0.2 290);
}

सिर्फ wrapper के अंदर का button ही override देखता है। बाहर, --brand pink ही रहता है।

कोई focus rings नहीं

Flow UI कहीं भी ring utilities use नहीं करता। Focus indication border-color को --focus में swap करता है और (optionally) --border-width-focus बढ़ाता है। नतीजा: focus transitions में stable layout, component की bounding box के बाहर कोई halo नहीं।

अगर आप --focus override करते हैं, तो UI का हर focused element उसे follow करेगा।

On this page