Props
Usage guidelines
- As symbolic communication for elements that do not have room for text, like the number of pins in a carousel. In this case, ensure the icon choice is easily recognizable and makes sense to international users.
- To convey a critical meaning that cannot be communicated with words, like a downward chevron in a Button to indicate it reveals a menu.
- To help with quick scanning by adding rhythm and hierarchy to the design.
- For purposes that are decorative or for visual embellishment, such as how illustrations are typically used. Contact us if this is needed.
- As a visual reinforcement for associated text, without adding new meaning.
- To communicate status or health. Use Status instead.
- As an interactive element (e.g., utilizing hover, focus, click/tap). Use IconButton instead.
Best practices
Use icons intentionally, ensuring the Icon choice is easily recognizable and makes sense in the context.
Repurpose icons. Using icons for their intended meaning supports good comprehension.
Pair text and icons when possible to provide better clarity.
Don't create interactive Icons using TapArea. Use IconButton instead.
Accessibility
Icons are a great way to help users who have difficulties with reading, focus attention, and low vision impairments.
ARIA attributes
If the icon appears without text, the Icon requires accessibilityLabel
, a text description for screen readers to announce and communicate the represented Icon, as shown in the first example.
Avoid using the generic words like "image" or "icon"; instead, use verbs that describe the meaning of the icon, for example: “pins".
If an icon has a visible label that describes what the icon represents, accessibilityLabel
can be an empty string, as shown in the second example.
import { Text, Icon, Flex } from 'gestalt'; export default function Example() { return ( <Flex alignItems="center" height="100%" justifyContent="center" width="100%" > <Flex gap={2} alignItems="center"> <Icon icon="eye" accessibilityLabel="Number of views" color="default" /> <Text weight="bold" size="300"> 4 </Text> </Flex> </Flex> ); }
import { Text, Icon, Flex } from 'gestalt'; export default function Example() { return ( <Flex alignItems="center" height="100%" justifyContent="center" width="100%" > <Flex alignItems="center" gap={2}> <Icon icon="tag" accessibilityLabel="" color="default" /> <Text size="300" weight="bold"> Shopping spotlight </Text> </Flex> </Flex> ); }
Legibility and touch area
Ensure that icons use a contrast ratio of 4.5:1 between icon color and background color.
Localization
Be sure to localize accessibilityLabel
.
Variants
Colors
Icons can be created using the following color options. brandPrimary
should only be used to represent the Pinterest logo, as it is not accessible. See the design tokens for more info.
Size
These are the guidelines for icon sizes (in px):
12
Used sparingly in tight spaces. When possible, use a text label next to the icon, as it can be hard to see for visually impaired people.14
Used often following body text content any time an icon is needed.16
Used often any time an icon is needed. Default icon size.24
Used frequently any time an icon is needed.32
Used occasionally, on more dense UI.32+
Should be used sparingly and only in places where the UI is very dense and a larger icon is required.
Custom icon
Icon accepts both Gestalt icons and custom icons, as shown in the second example. For custom icons, follow the iconography and SVG guidelines.
import { Tooltip, Icon, Flex } from 'gestalt'; export default function Example() { return ( <Flex alignItems="center" height="100%" justifyContent="center" width="100%" > <Tooltip text="Built-in Gestalt Icon"> <Icon accessibilityLabel="Go to next steps" icon="directional-arrow-right" /> </Tooltip> </Flex> ); }
import { Tooltip, Icon, Flex } from 'gestalt'; export default function Example() { return ( <Flex alignItems="center" height="100%" justifyContent="center" width="100%" > <Tooltip text="Custom Icon"> <Icon accessibilityLabel="Go to next steps" dangerouslySetSvgPath={{ __path: 'M23 5v14a4 4 0 0 1-4 4H5a4 4 0 0 1-4-4v-5.5h10.258l-1.94 1.939a1.5 1.5 0 0 0 2.121 2.122L17 12l-5.561-5.561a1.501 1.501 0 0 0-2.121 2.122l1.94 1.939H1V5a4 4 0 0 1 4-4h14a4 4 0 0 1 4 4', }} /> </Tooltip> </Flex> ); }
Writing
Use a descriptive label to describe the Icon
- Be succinct. Exclude unnecessary words.
- Be informative and accurate
- Write in the active voice
- Avoid technical jargon
- Use the words "image" or "icon" in the description label; instead, use words that indicate the purpose of the icon.
Component quality checklist
Quality item | Status | Status description |
---|---|---|
Figma Library | Ready | Component is available in Figma across all platforms. |
Responsive Web | Ready | Component is available in code for web and mobile web. |
iOS | Planned | Component is slotted to be built for iOS. |
Android | Planned | Component is slotted to be built for Android. |
Related
IconButton
Use IconButton when only an icon is needed to represent an action instead of text.
Button
Use Button to allow users to take an action.