createId
Generate unique, SSR-safe identifiers for accessibility relationships and form controls.
createId returns an accessor for a string identifier used in accessibility bindings (aria-labelledby, aria-describedby, aria-controls, for). It returns the ID you supply when there is one, and otherwise a prefixed ID from Solid’s createUniqueId().
Import#
Signature#
Usage Example#
src/CustomField.tsx
Priority Rules#
- If
deterministicIdreturns a non-empty string, the accessor returns that string. - Otherwise (the function is omitted, or returns
null,undefined, or an empty string), the accessor returns the generated ID:prefix(default'mo'), a hyphen, and Solid’screateUniqueId().
The generated ID is created once per call, so it stays stable when deterministicId changes between a string and undefined. Because it comes from createUniqueId(), server and client render the same ID during hydration.