diff --git a/packages/grafana-ui/src/components/Icon/Icon.mdx b/packages/grafana-ui/src/components/Icon/Icon.mdx index 3246e997427..ae41fea0926 100644 --- a/packages/grafana-ui/src/components/Icon/Icon.mdx +++ b/packages/grafana-ui/src/components/Icon/Icon.mdx @@ -7,6 +7,14 @@ import { Icon } from './Icon'; Grafana's wrapper component over [Font Awesome](https://fontawesome.com/) and Unicons icons +## Accessibility + +`Icon` is aria-hidden by default. If your icon has semantic meaning, please provide a `title` or wrap it in a `Tooltip`. + +### Usage with Tooltip + +If you decide to use a `Tooltip` to wrap `Icon`, you need to set a `title` or `aria-label` on the `Icon` component in order for it to appear in the accessibility tree. `Tooltip` only provides `aria-describedby` on interaction. + ### Changing icon size By default `Icon` has width and height of `16px` and font-size of `14px`. Pass `className` to control icon's size: diff --git a/packages/grafana-ui/src/components/Icon/Icon.tsx b/packages/grafana-ui/src/components/Icon/Icon.tsx index 8e08714225c..d33ed422b4d 100644 --- a/packages/grafana-ui/src/components/Icon/Icon.tsx +++ b/packages/grafana-ui/src/components/Icon/Icon.tsx @@ -13,6 +13,9 @@ export interface IconProps extends Omit, 'onLoad' | ' name: IconName; size?: IconSize; type?: IconType; + /** + * Give your icon a semantic meaning. The icon will be hidden from screen readers, unless this prop or an aria-label is provided. + */ title?: string; } @@ -60,6 +63,13 @@ export const Icon = React.forwardRef( return ( undefined }: RulesFilerProps) => } > - + @@ -232,7 +237,7 @@ const RulesFilter = ({ onFilterCleared = () => undefined }: RulesFilerProps) => Search }> - + diff --git a/public/app/plugins/datasource/cloud-monitoring/components/__snapshots__/VariableQueryEditor.test.tsx.snap b/public/app/plugins/datasource/cloud-monitoring/components/__snapshots__/VariableQueryEditor.test.tsx.snap index b52a8a3d64b..e16162d1e3d 100644 --- a/public/app/plugins/datasource/cloud-monitoring/components/__snapshots__/VariableQueryEditor.test.tsx.snap +++ b/public/app/plugins/datasource/cloud-monitoring/components/__snapshots__/VariableQueryEditor.test.tsx.snap @@ -91,6 +91,7 @@ exports[`VariableQueryEditor renders correctly 1`] = ` className="css-zyjsuv-input-suffix" >