Icon
Use this component to clarify the meaning of UI elements and improve scannability. Icons are intended to visually communicate actions, status, content, or feedback.
#Examples
The Icon component features a few properties for adjusting its appearance. The following sections showcase these properties and explain when and how to use them.
#Default
To use the Icon component, first find the name of the icon you need on the icons overview page. Then, wrap it in Icon
tags, as shown in the example below.
<Icon>
<IconSettings />
</Icon>
#Size
Use the size
property to adjust an icon’s size. The default size is large
. Choose a size based on available space, how important it is for the user to notice the icon, and the size of the icon's label. You can also use the responsive
size if you need the icon to scale along with the font size of the parent element.
<Icon size="small">
<IconClose />
</Icon>
<Icon size="medium">
<IconClose />
</Icon>
<Icon size="large">
<IconClose />
</Icon>
<div style={{ display: "inline-flex", fontSize: "2rem" }}>
<Icon size="responsive">
<IconClose />
</Icon>
</div>
#Rotation
Use the rotation
property to rotate an icon either 0
, 90
, 180
, or 270
degrees. This property removes the need for having up to four different versions of certain directional icons, such as chevrons and carets. Also, when the rotation
property changes, the icon animates to the new value. This effect can function as visual feedback when the Icon is part of an interactive UI element.
<Icon rotation="0">
<IconChevron />
</Icon>
<Icon rotation="90">
<IconChevron />
</Icon>
<Icon rotation="180">
<IconChevron />
</Icon>
<Icon rotation="270">
<IconChevron />
</Icon>
#Fill
Use the fill
property to change the color of an icon. The fill
property’s default value is currentColor
. This means it inherits its value from the existing color
value. In other words, an icon will by default have the same color as surrounding text.
Make sure to only use colors that are part of our design tokens. This means you have to import the color in question, as shown in the example below. Omit the comment slashes in your code.
<Icon fill={ColorRed}>
<IconChevron />
</Icon>
#Properties
Property | Description | Defined | Value |
---|---|---|---|
childrenRequired | element A icon to be cloned and applied relevant styling to | ||
sizeOptional | "large" | "medium" | "responsive" | "small" Controls the width and height of the component, defaults to `"large"` | ||
rotationOptional | "0" | "180" | "270" | "90" How many degrees the icon should be rotated, will be animated if changed from one value to another | ||
fillOptional | string If the icon should have another color |
#Guidelines
#Best practices
#Do not use when
#Accessibility
Ensure a contrast ratio of at least 3:1 between the color of an Icon
and its background. Other than that, accessible use of the Icon
component depends mainly on whether the icon is part of an interactive UI element and has a visible label. What to do in each scenario is explained below.
#Interactive icon with visible label
#Interactive icon without visible label
#Static icon with visible label
#Static icon without visible label
Explore detailed guidelines for this component: Accessibility Specifications
#Writing
#Notable changes
#Version 0.0.x
IconRobot
has been renamed toIconAssistiveTechnology
.IconPollutingFactory
has been renamed toIconIndustryBenchmark
.IconCornerArrow
has been renamed toIconArrowDownLeft
.- The (unused)
flip
property was removed, which function was to flip icons on the x-axis.