FLOWDocs

Utilities

cn(), useIsMobile(), और shared patterns।

हर Flow UI component द्वारा use की जाने वाली helpers का एक छोटा set।

cn()

Class names को clsx जैसा merge करता है, साथ ही conflicting Tailwind utilities को de-duplicate भी करता है। जहाँ भी आप अकेले clsx use करते हैं वहाँ इसे use करें।

import { cn } from "@flow-industries/ui";

cn("p-4", condition && "bg-brand", className);
// → "p-4 bg-brand <whatever caller passed>"

cn("p-4 p-6");
// → "p-6" (later wins, clsx + tailwind-merge de-duped)

हर Flow component अपने root element पर internally cn() call करता है, इसलिए आप जो भी className pass करें वह built-in classes के साथ predictably compose होता है।

useIsMobile()

एक boolean return करता है जो एक standard breakpoint (default: 768px) के नीचे flip होता है। Resize पर live-update होता है।

import { useIsMobile } from "@flow-industries/ui";

function Nav() {
  const isMobile = useIsMobile();
  return isMobile ? <MobileNav /> : <DesktopNav />;
}

यह hook (max-width: 767px) match करता है। अगर आपको कोई दूसरा breakpoint चाहिए तो matchMedia से अपना खुद का लिखें — Flow hook बस common case है।

Shared patterns

render prop (asChild नहीं)

Flow UI Base UI पर बना है, इसलिए composition render prop use करता है:

<Button render={<a href="/home" />}>Home</Button>

Button styles और behavior वाला एक <a> render करता है। asChild use न करें — वह Radix है, Base UI नहीं।

data-slot attributes

हर component अपने root को data-slot="<name>" से tag करता है। Generated class names से जूझे बिना consumers में style या query करें:

[data-slot="button"] {
  font-feature-settings: "tnum";
}

Reduced motion

Motion-driven components — Accordion, Tabs, WordFlash, और animated icons — motion/react से useReducedMotion() call करते हैं ताकि user के reduced motion prefer करने पर अपने JS-driven transitions skip या छोटा कर सकें। बाकी सब base.css में मौजूद एक global @media (prefers-reduced-motion: reduce) reset से अपने-आप cover हो जाता है, जो बचे हुए सभी CSS animations और transitions को collapse कर देता है — इसलिए आपको इसे खुद कभी wire up नहीं करना पड़ता।

कोई transition-all नहीं

Flow UI components exact transition properties specify करते हैं — transition-colors, transition-[border-color,background-color], कभी transition-all नहीं। अगर आप styles override करें तो इसी discipline का पालन करें ताकि padding, font-size, या layout accidentally animate न हो।

On this page