IdGenerator

Primitive #2

🔍 Problem it solves

Two instances of the same component (e.g., two Dialogs) need unique IDs for ARIA attributes like aria-labelledby and aria-describedby. If they share IDs, screen readers break. Also problematic during SSR because IDs must be stable between server and client.

✅ Solution

Generates stable, unique IDs per component instance using a prefix and a counter. The ID is deterministic on both server and client, preventing hydration mismatches.

🧩 Used by components

Dialog, Popover, Tabs, Accordion, Tooltip, RadioGroup, Combobox, Listbox, Toast

🎮 Interactive demo