Skip to content

Commit b8b4697

Browse files
authored
Merge pull request #1981 from ember-learn/ef4-patch-1
Demonstrating unique-id helper
2 parents 3a69cfa + f2e9a50 commit b8b4697

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

guides/release/accessibility/components.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,15 @@ However, the most common methods for providing accessible names can be reviewed
5757

5858
### Adding a label to an input element
5959

60-
Every `<input>` element should have an associated `<label>` element. To do this, the `<input>` element's `id` attribute value should be the same as the `for` attribute value on the `<label>`, like this:
60+
Every `<input>` element should have an associated `<label>` element. To do this, the `<input>` element's `id` attribute value should be the same as the `for` attribute value on the `<label>`. Ember has a built-in `unique-id` helper that can generate unique ids that you can use like this:
6161

6262
![Separate input and label elements with a connection established by matching for and id attributes](/images/accessibility/component-considerations/input-for-id.png)
6363

6464
```html
65-
<label for="input-name">Name:</label>
66-
<input id="input-name" name="name" value="" type="text" />
65+
{{#let (unique-id) as |id|}}
66+
<label for={{id}}>Name:</label>
67+
<input id={{id}} name="name" value="" type="text" />
68+
{{/let}}
6769
```
6870

6971
It is also valid to wrap the `<label>` element around the `<input />` element:

0 commit comments

Comments
 (0)