Composables

useId

Source
Generate a stable unique id for aria/id/for wiring, or pass one through deterministically.
Advanced. This is a primitive-authoring utility from @vyui/core that most app code never calls directly.

Overview

import { useId } from '@vyui/core'

const id = useId() // 'vy-1'
const forced = useId(props.id) // pass a deterministic id to skip generation

Generates a stable unique id for id / for / aria-* wiring, preferring Vue 3.5+'s built-in useId() and falling back to an internal counter on older Vue.

Signature

useId(deterministicId?: string | null, prefix = 'vy'): string

  • deterministicId is returned verbatim when set, skipping generation entirely.
  • prefix is prepended to the generated id ('vy' by default). Pass '' for a bare id.