From 0d286fa048afaf7b25485316fd7d7d47356c65b1 Mon Sep 17 00:00:00 2001 From: Carlos Dourado Date: Sun, 10 May 2026 03:57:31 -0400 Subject: [PATCH] docs: mention useId for accessible ids --- src/guide/best-practices/accessibility.md | 36 +++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/guide/best-practices/accessibility.md b/src/guide/best-practices/accessibility.md index 2651f2d0b8..ef2dfa4406 100644 --- a/src/guide/best-practices/accessibility.md +++ b/src/guide/best-practices/accessibility.md @@ -229,6 +229,42 @@ Using [`aria-labelledby`](https://developer.mozilla.org/en-US/docs/Web/Accessibi ![Chrome Developer Tools showing input accessible name from aria-labelledby](./images/AccessibleARIAlabelledbyDevTools.png) +:::tip IDs in reusable components +If this pattern is used inside a component that may be rendered more than once on a page, avoid hard-coded IDs since `id` attributes must be unique in the entire document. Use [`useId()`](/api/composition-api-helpers.html#useid) to generate stable, unique IDs for accessibility attributes: + +```vue + + + +``` +::: + #### `aria-describedby` {#aria-describedby} [aria-describedby](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-describedby) is used the same way as `aria-labelledby` except provides a description with additional information that the user might need. This can be used to describe the criteria for any input: