Composables

useId

Source
Generate a stable unique id for aria/id/for wiring, or pass one through deterministically.
Advanced. Primitive-authoring utility from @vyui/core — most app code never calls this 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 — returned verbatim when set, skipping generation entirely.
  • prefix — prepended to the generated id ('vy' by default). Pass '' for a bare id.