useId

Utilities
Local guide ↗

Accessible field IDs

Generate unique, hydration-stable IDs once and use them to connect labels to controls

bits-94
bits-95

Click either label to focus its control

unique IDs

Call useId() during component initialization, not in an event handler or a changing loop. The returned value can connect label[for] to a control's id, or wire ARIA relationships without requiring a caller-supplied identifier.

Bits UI uses the same generator internally for component relationships. Keeping the call order stable between server rendering and hydration keeps those IDs aligned; each call in one component instance returns a distinct value.