Skip to content

Commit 21fef1b

Browse files
committedOct 26, 2022
docs: add accessibility explanation to svgProps option
1 parent 1382232 commit 21fef1b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
 

‎website/pages/docs/options.mdx

+22
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,28 @@ Add props to the root SVG tag.
170170

171171
> You can specify dynamic property using curly braces: `{ focusable: "{true}" }` or `--svg-props focusable={true}`. It is particularly useful with a custom template.
172172
173+
### Accessibility
174+
175+
SVGs by default have an implicit `role="graphics-document"`. To make SVG content accessible you may want to override the default behavior which can be done via the `svgProps` override.
176+
177+
#### For web:
178+
179+
| Default | CLI Override | API Override |
180+
| ------- | ---------------------- | --------------------------- |
181+
| `[]` | `--svg-props role=img` | `svgProps: { role: 'img' }` |
182+
183+
#### For native:
184+
185+
| Default | CLI Override | API Override |
186+
| ------- | ------------------------------------- | ------------------------------------------ |
187+
| `[]` | `--svg-props accessibilityRole=image` | `svgProps: { accessibilityRole: 'image' }` |
188+
189+
Typically for role=img you will want to add either `alt` text or `aria` label/description properties to describe the image when rendering the SVG in your application.
190+
191+
> **NOTE**: On the web once you add `role: 'img'` some screen-readers will automatically announce any `title`/`text`/`desc` nodes within your SVG.
192+
>
193+
> SVGO can be configured to remove those nodes via the built-in `removeDesc` and `removeTitle` plugins if you only want to use `aria` properties during consumption of the SVGs.
194+
173195
## Title
174196

175197
Add title tag via title property. If titleProp is set to true and no title is provided (`title={undefined}`) at render time, this will fallback to an existing title element in the svg if exists.

0 commit comments

Comments
 (0)
Please sign in to comment.