Skip to content

Material 3

Components

Icon

Icons display Material Symbols.

9:30
Shortcuts
Home
Favorites
Search
Mail
Photos
Maps
Music
Calendar
Settings

Icons are small symbols for actions, objects and ideas. Use them beside a label to make it easier to scan, or alone in a control that has an accessible name, such as an icon button.

The library supports icons in two ways:

  1. With the Icon component, which shows a Material Symbols icon by its name.
  2. With any other icon, such as one from an SVG icon library, written in place of an Icon.
import { Icon } from '@material-web/react'

Basic icon

Icon shows an icon from the Material Symbols font. It takes the color of the text around it, and its size, fill, weight and grade from classes.

import { Icon } from '@material-web/react'

export default function Basic() {
  return (
    <div className="flex gap-space-300 icon-24">
      <Icon name="home" />
      <Icon name="search" />
      <Icon name="favorite" />
      <Icon name="settings" />
      <Icon name="arrow_back" />
    </div>
  )
}

The icon font is not bundled. Load Material Symbols as Installation shows.

Set name to the ligature name of a Material Symbols icon, such as home or arrow_back. Look up the names in the Material Symbols library. name is the only prop specific to Icon: style the icon with the classes below.

To show an icon in an element of your own, give that element the font-icon class and write the name as its text.

<span className="font-icon icon-24" aria-hidden>
  home
</span>

Color

An icon takes the text color of the element it is in. To give it another color role, pass a text color class in className, or set the class on an element around it.

import { Icon } from '@material-web/react'

export default function Color() {
  return (
    <div className="flex gap-space-300 icon-32">
      <Icon name="favorite" />
      <Icon name="favorite" className="text-primary" />
      <Icon name="favorite" className="text-tertiary" />
      <Icon name="favorite" className="text-error" />
      <span className="flex gap-space-300 text-on-surface-variant">
        <Icon name="home" />
        <Icon name="search" />
      </span>
    </div>
  )
}

Sizes

Set an icon's size with icon- and a number of dp, such as icon-18 to icon-48, the Material 3 icon sizes, or with a length, such as icon-[1.5rem]. The icon takes a square box of that size.

import { Icon } from '@material-web/react'

export default function Sizes() {
  return (
    <>
      <Icon name="star" className="icon-18" />
      <Icon name="star" className="icon-20" />
      <Icon name="star" className="icon-24" />
      <Icon name="star" className="icon-32" />
      <Icon name="star" className="icon-40" />
      <Icon name="star" className="icon-48" />
    </>
  )
}

Put the class on the icon or on any element around it. Like a font size, it is inherited: an icon uses its own class first, then the nearest one around it. The class does not change the size of the text. Without one, the icon is as large as the font size it inherits, 16dp in body-large text.

Saved, with a 24dp icon from what holds it

Saved, with an icon of the font size it inherits

import { Icon } from '@material-web/react'

export default function Inherited() {
  return (
    <div className="flex flex-col gap-space-200">
      <p className="m-0 text-body-lg icon-24">
        <Icon name="info" /> Saved, with a 24dp icon from what holds it
      </p>
      <p className="m-0 text-body-lg">
        <Icon name="info" /> Saved, with an icon of the font size it inherits
      </p>
    </div>
  )
}

Fill

Use icon-filled to fill an icon and icon-outlined to keep it outlined. The fill is inherited in the same way as the size: icon-filled on a parent fills every icon in it, except one with icon-outlined.

import { Icon } from '@material-web/react'

export default function Fill() {
  return (
    <>
      <Icon name="favorite" className="icon-40" />
      <Icon name="favorite" className="icon-40 icon-filled" />
      <div className="flex gap-space-200 text-primary icon-40 icon-filled">
        <Icon name="home" />
        <Icon name="bookmark" />
        <Icon name="delete" className="icon-outlined" />
      </div>
    </>
  )
}

Weight

Set an icon's stroke weight with a font weight class, such as font-medium. The default weight is 400.

import { Icon } from '@material-web/react'

export default function Weight() {
  return (
    <div className="flex gap-space-300 icon-40">
      <Icon name="settings" className="font-thin" />
      <Icon name="settings" className="font-light" />
      <Icon name="settings" />
      <Icon name="settings" className="font-medium" />
      <Icon name="settings" className="font-bold" />
    </div>
  )
}

Grade

Use -icon-grade-25 for low emphasis and icon-grade-200 for high emphasis. The default grade is 0. The grade is inherited in the same way as the fill.

import { Icon } from '@material-web/react'

export default function Grade() {
  return (
    <div className="flex gap-space-300 icon-40">
      <Icon name="notifications" className="-icon-grade-25" />
      <Icon name="notifications" />
      <Icon name="notifications" className="icon-grade-200" />
    </div>
  )
}

Right to left

Use rtl:icon-mirrored to flip an icon in a right-to-left layout. Apply it to an icon that implies a direction, such as arrow_back, and not to a symbol that keeps its meaning there, such as check.

Left to right
Right to left
import { Icon } from '@material-web/react'

export default function Mirrored() {
  return (
    <>
      <div dir="ltr" className="flex items-center gap-space-200 icon-32">
        <Icon name="arrow_back" className="rtl:icon-mirrored" />
        <Icon name="check" />
        <span className="text-label-lg text-on-surface-variant">Left to right</span>
      </div>
      <div dir="rtl" className="flex items-center gap-space-200 icon-32">
        <Icon name="arrow_back" className="rtl:icon-mirrored" />
        <Icon name="check" />
        <span className="text-label-lg text-on-surface-variant">Right to left</span>
      </div>
    </>
  )
}

In components

A component sizes the icons in it, so an icon in a Button, a Chip, a ListItem or a MenuItem needs no size class. A selected navigation, list or menu item fills the icons in it. Add icon-outlined to an icon to keep it outlined there.

Inbox
Sent
import { Button, Icon, List, ListItem } from '@material-web/react'
import { Text } from 'react-aria-components'

export default function InComponents() {
  return (
    <>
      <Button>
        <Icon name="add" />
        Create
      </Button>
      <Button size="l">
        <Icon name="add" />
        Create
      </Button>
      <List aria-label="Folders" selectionMode="single" defaultSelectedKeys={['inbox']}>
        <ListItem id="inbox" textValue="Inbox">
          <Icon slot="leading" name="inbox" />
          <Text slot="label">Inbox</Text>
        </ListItem>
        <ListItem id="sent" textValue="Sent">
          <Icon slot="leading" name="send" />
          <Text slot="label">Sent</Text>
        </ListItem>
      </List>
    </>
  )
}

In a component with icon slots, such as a ListItem, a MenuItem or a Chip, set the icon's slot to one of them. Any other slot throws an Invalid slot error. See Slots.

Other libraries

Any icon works in place of Icon. Button, IconButton, Fab and SplitButtonLeading take an icon as a child, and Chip takes one as a child in its leading or trailing slot, so those components need no other change.

To use an icon from an SVG icon library, or your own component, write it in place of the Icon and size it to fill the slot. A component sizes only the Icon it holds. See Icons.

import { Button } from '@material-web/react'
import type { ComponentProps } from 'react'

function Plus(props: ComponentProps<'svg'>) {
  return (
    <svg
      viewBox="0 0 24 24"
      fill="none"
      stroke="currentColor"
      strokeWidth="2"
      aria-hidden
      {...props}
    >
      <path d="M12 5v14M5 12h14" />
    </svg>
  )
}

export default function OtherLibrary() {
  return (
    <Button>
      <Plus className="size-5" />
      Create
    </Button>
  )
}

Customization

Pass classes in className to restyle one icon, or set them on an element around it: the size, fill and grade classes are inherited. A class of yours replaces the icon's own class for the same property. See Styling for the classes and the theme.

  • Size: Pass an icon- class, as in Sizes.
  • Color: Pass a text color class, as in Color.
  • Functions: An icon reports no state, so className and style take a value and cannot be a function.
  • Every icon: To show every icon in another font, see Custom font.

Custom font

Icon shows Material Symbols by default. To use another ligature font with Icon, override --font-icon, and load that font. See Custom fonts.

:root {
  --font-icon: 'Material Symbols Rounded';
}