IconButton ready Storybook
ready
IconButton
s are actionable buttons that show only an icon. Since there is no regular label it’s critical to include a tooltip with all IconButtons so the label can be accessible on hover.
Do’s
- Always include the button label in a tooltip
- In exceptional cases where the tooltip does not make sense and the icon is unambiguous (e.g for expanding a folder): add aria-label and the tooltip will be removed.
- When using
IconButton
together with text make sure to align them by adding a wrapper withdisplay: flex
andalign-items: center
- Use in areas that are limited in space and are low-context
- Ensure the meaning of the icon is well understood and unambiguous
- Use
IconButton
instead of Button with only an icon
Don’ts
- Do not use in hight-context situations
Variants
Type | Style | Purpose |
---|---|---|
Primary | Ghost | Used for primary-based actions, only use one per section. If there is no primary action, all Button components should be secondary. |
Secondary | Ghost | Default-styling of buttons, this style is used the most within Grafana and can trigger various actions. |
Destructive | Ghost | Used for delete actions |
Disabled | Ghost | If the functionality the IconButton provides is not available but the IconButton is supposed to show that there is this kind of functionality. |
Formatting
Anatomy
- Icon
- Container (on hover)
Placement
IconButton
s are best used in areas that are limited in space and are action-heavy. These could be toolbars or in areas that provide inline editing such as tables or cards.
Button Sizes
icon size | name & size in Figma | name & size in code |
---|---|---|
12px | small: 20px | xs: 20px |
14px | sm: 22px | |
16px | medium: 28px | md: 24px |
18px | lg: 26px | |
24px | large: 48px | xl: 32px |
24px | xxl: 32px | |
24px | xxxl: 32px |
Accessibility
- Add a text for tooltip (it will also be used as the aria-label)
- In exceptional cases where the tooltip does not make sense add the aria-label.
Behaviours
Hover
On hover, the IconButton
displays a tooltip that includes the IconButton’s label.