mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-12-03 16:59:42 +00:00
fix(packages): only remove aria-hidden when an accessibility prop is set (#5347)
* Adjust accessibility behaviour for title elements * Adjust angular package as well * Fix types * fix(packages/angular): use fixture.whenStable instead of triggering change detection manually detectChanges() explicitly forces a check, so it can mask missing automatic change detection * test(packages/angular): add test for non-signal bound aria attribute * fix(angular): preserve explicit aria-hidden and support input bindings --------- Co-authored-by: Karsa <contact@karsa.org>
This commit is contained in:
@@ -23,12 +23,16 @@ Only if an icon **conveys essential meaning on its own** should it be made acces
|
||||
|
||||
## Making an Icon Accessible
|
||||
|
||||
To expose an icon to assistive technologies, provide an accessible name by binding the `title` input of the icon component.
|
||||
To expose an icon to assistive technologies, provide an accessible name by binding the `title` input of the icon component, or by setting an `aria-label` attribute on it.
|
||||
|
||||
This removes the `aria-hidden` attribute and makes the icon visible to screen readers.
|
||||
Setting the `title` input, or any `aria-*` or `role` attribute, stops the icon from being hidden from screen readers.
|
||||
|
||||
```angular-html
|
||||
<svg lucideHouse title="This is my house" />
|
||||
|
||||
<!-- or -->
|
||||
|
||||
<svg lucideHouse aria-label="This is my house" />
|
||||
```
|
||||
|
||||
Choose a label that clearly describes the meaning of the icon or the action it represents in the context of your application.
|
||||
|
||||
@@ -23,13 +23,13 @@ Only if an icon **conveys essential meaning on its own** should it be made acces
|
||||
|
||||
## Making an icon accessible
|
||||
|
||||
To expose an icon to assistive technologies, provide an accessible name by passing a `title` element as a child or passing the `aria-label` prop to the icon component.
|
||||
To expose an icon to assistive technologies, provide an accessible name by passing the `aria-label` prop to the icon component, or by passing a `title` element as a child and referencing it with `role="img"` and `aria-labelledby`.
|
||||
|
||||
This removes the `aria-hidden` attribute and makes the icon visible to screen readers.
|
||||
Passing an `aria-*`, `role` or `title` prop removes the `aria-hidden` attribute and makes the icon visible to screen readers. A `title` child on its own does not: without those props the icon stays hidden.
|
||||
|
||||
```astro
|
||||
<House>
|
||||
<title>This is my house</title>
|
||||
<House role="img" aria-labelledby="house-title">
|
||||
<title id="house-title">This is my house</title>
|
||||
</House>
|
||||
|
||||
// or
|
||||
|
||||
@@ -23,13 +23,13 @@ Only if an icon **conveys essential meaning on its own** should it be made acces
|
||||
|
||||
## Making an icon accessible
|
||||
|
||||
To expose an icon to assistive technologies, provide an accessible name by passing a `title` element as a child or passing the `aria-label` prop to the icon component.
|
||||
To expose an icon to assistive technologies, provide an accessible name by passing the `aria-label` prop to the icon component, or by passing a `title` element as a child and referencing it with `role="img"` and `aria-labelledby`.
|
||||
|
||||
This removes the `aria-hidden` attribute and makes the icon visible to screen readers.
|
||||
Passing an `aria-*`, `role` or `title` prop removes the `aria-hidden` attribute and makes the icon visible to screen readers. A `title` child on its own does not: without those props the icon stays hidden.
|
||||
|
||||
```tsx
|
||||
<House>
|
||||
<title>This is my house</title>
|
||||
<House role="img" aria-labelledby="house-title">
|
||||
<title id="house-title">This is my house</title>
|
||||
</House>
|
||||
|
||||
// or
|
||||
|
||||
@@ -22,13 +22,13 @@ Only if an icon **conveys essential meaning on its own** should it be made acces
|
||||
|
||||
## Making an icon accessible
|
||||
|
||||
To expose an icon to assistive technologies, provide an accessible name by passing a `title` element as a child or passing the `aria-label` prop to the icon component.
|
||||
To expose an icon to assistive technologies, provide an accessible name by passing the `aria-label` prop to the icon component, or by passing a `title` element as a child and referencing it with `role="img"` and `aria-labelledby`.
|
||||
|
||||
This removes the `aria-hidden` attribute and makes the icon visible to screen readers.
|
||||
Passing an `aria-*`, `role` or `title` prop removes the `aria-hidden` attribute and makes the icon visible to screen readers. A `title` child on its own does not: without those props the icon stays hidden.
|
||||
|
||||
```tsx
|
||||
<House>
|
||||
<title>This is my house</title>
|
||||
<House role="img" aria-labelledby="house-title">
|
||||
<title id="house-title">This is my house</title>
|
||||
</House>
|
||||
|
||||
// or
|
||||
|
||||
@@ -22,13 +22,13 @@ Only if an icon **conveys essential meaning on its own** should it be made acces
|
||||
|
||||
## Making an icon accessible
|
||||
|
||||
To expose an icon to assistive technologies, provide an accessible name by passing a `title` element as a child or passing the `aria-label` prop to the icon component.
|
||||
To expose an icon to assistive technologies, provide an accessible name by passing the `aria-label` prop to the icon component, or by passing a `title` element as a child and referencing it with `role="img"` and `aria-labelledby`.
|
||||
|
||||
This removes the `aria-hidden` attribute and makes the icon visible to screen readers.
|
||||
Passing an `aria-*`, `role` or `title` prop removes the `aria-hidden` attribute and makes the icon visible to screen readers. A `title` child on its own does not: without those props the icon stays hidden.
|
||||
|
||||
```tsx
|
||||
<House>
|
||||
<title>This is my house</title>
|
||||
<House role="img" aria-labelledby="house-title">
|
||||
<title id="house-title">This is my house</title>
|
||||
</House>
|
||||
|
||||
// or
|
||||
|
||||
@@ -23,13 +23,13 @@ Only if an icon **conveys essential meaning on its own** should it be made acces
|
||||
|
||||
## Making an icon accessible
|
||||
|
||||
To expose an icon to assistive technologies, provide an accessible name by passing a `title` element as a child or passing the `aria-label` prop to the icon component.
|
||||
To expose an icon to assistive technologies, provide an accessible name by passing the `aria-label` prop to the icon component, or by passing a `title` element as a child and referencing it with `role="img"` and `aria-labelledby`.
|
||||
|
||||
This removes the `aria-hidden` attribute and makes the icon visible to screen readers.
|
||||
Passing an `aria-*`, `role` or `title` prop removes the `aria-hidden` attribute and makes the icon visible to screen readers. A `title` child on its own does not: without those props the icon stays hidden.
|
||||
|
||||
```svelte
|
||||
<House>
|
||||
<title>This is my house</title>
|
||||
<House role="img" aria-labelledby="house-title">
|
||||
<title id="house-title">This is my house</title>
|
||||
</House>
|
||||
|
||||
// or
|
||||
|
||||
@@ -23,13 +23,13 @@ Only if an icon **conveys essential meaning on its own** should it be made acces
|
||||
|
||||
## Making an icon accessible
|
||||
|
||||
To expose an icon to assistive technologies, provide an accessible name by passing a `title` element as a child or passing the `aria-label` prop to the icon component.
|
||||
To expose an icon to assistive technologies, provide an accessible name by passing the `aria-label` prop to the icon component, or by passing a `title` element as a child and referencing it with `role="img"` and `aria-labelledby`.
|
||||
|
||||
This removes the `aria-hidden` attribute and makes the icon visible to screen readers.
|
||||
Passing an `aria-*`, `role` or `title` prop removes the `aria-hidden` attribute and makes the icon visible to screen readers. A `title` child on its own does not: without those props the icon stays hidden.
|
||||
|
||||
```vue
|
||||
<House>
|
||||
<title>This is my house</title>
|
||||
<House role="img" aria-labelledby="house-title">
|
||||
<title id="house-title">This is my house</title>
|
||||
</House>
|
||||
|
||||
// or
|
||||
|
||||
Reference in New Issue
Block a user