ConstGenerate a unique ID, optionally with a prefix.
// Basic usage
const id = yield* UniqueId.make()
// => "uid-1"
// With prefix
const contentId = yield* UniqueId.make("collapsible-content")
// => "collapsible-content-1"
// For ARIA relationships
Effect.gen(function* () {
const labelId = yield* UniqueId.make("label")
const inputId = yield* UniqueId.make("input")
return yield* $.div([
$.label({ id: labelId, htmlFor: inputId }, "Name"),
$.input({ id: inputId, "aria-labelledby": labelId }),
])
})
Generate unique IDs for DOM elements. Useful for ARIA relationships, label associations, and other cases where elements need to reference each other by ID.