Icon
Use the <Icon>
component to easily render <svg>
icons. Chakra UI provides
basic interface icons, to add your icons,
read the guide.
Avoid passing onClick
handlers to the Icon
component. If you need a
clickable icon, use IconButton instead.
Import#
Usage#
Use an icon by passing the name
props. This name must match an icon key in
theme.icons
. By default, the icon inherits the fontSize and color of it's
parent.
All Icons#
Here's a list of the default icons Chakra UI comes with and their respective
name
. You add your own icons as well, see the guide
copy
search
search-2
moon
sun
add
small-add
settings
check-circle
lock
unlock
view
view-off
download
delete
repeat
repeat-clock
edit
chevron-right
chevron-left
chevron-down
chevron-up
arrow-forward
arrow-up
arrow-down
arrow-back
external-link
link
plus-square
chat
calendar
time
attachment
up-down
at-sign
arrow-left
arrow-right
star
phone
spinner
drag-handle
close
small-close
not-allowed
triangle-down
triangle-up
bell
info-outline
info
question
question-outline
warning
warning-2
arrow-up-down
check
minus
Using an icon library#
Most times, you might need to use icons from a popular icon library like react-icons. Here's how to go about it.
Here's a working example:
Adding custom icons#
All Chakra icons are stored in the theme object under the icons
key. So you
can extend this object to add your own icons. Here are the steps:
- Export the icon's
svg
from Figma, Sketch, etc. - Use a tool like SvgOmg to reduce the size and minify the markup.
- Add the icon to the theme object.
Add the fill=currentColor
attribute to the path
or g
so that when you
this <Icon color="gray.200"/>
, it works correctly.
Icon Fallbacks#
If you pass an icon name that doesn't exist in theme.icons
, you'll see the
question-outline
icon.
Props#
Icon component composes Box
so you can pass all Box
props.
Name | Type | Default | Description |
---|---|---|---|
size | string | 1em | The size of the icon. |
name | string | The name of the icon. | |
color | string | currentColor | The color of the icon. |
focusable | boolean | false | Denotes that the icon is not an interative element, and only used for presentation. |
role | presentation , img | presentation | The html role of the icon. |