Introduction
Material UI provides icon support through three components and packages:- SvgIcon - A wrapper for custom SVG icons
- Icon - A component for displaying icon fonts (Material Icons, Font Awesome, etc.)
- @mui/icons-material - Over 2,100+ ready-to-use React components for Material Icons
SvgIcon
The SvgIcon component wraps SVG icons as React components. It extends the native<svg> element.
Basic Usage
Color
Thecolor prop supports theme palette colors.
Size
ThefontSize prop controls the size of the icon.
SvgIcon Props
| Prop | Type | Default | Description |
|---|---|---|---|
children | node | - | Node passed into the SVG element. |
classes | object | - | Override or extend the styles applied to the component. |
color | 'inherit' | 'action' | 'disabled' | 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning' | 'inherit' | The color of the component. |
fontSize | 'inherit' | 'large' | 'medium' | 'small' | 'medium' | The fontSize applied to the icon. Defaults to 24px. |
htmlColor | string | - | Applies a color attribute to the SVG element. |
inheritViewBox | boolean | false | If true, the root node will inherit the custom component’s viewBox. |
shapeRendering | string | - | The shape-rendering attribute for SVG element. |
sx | SxProps<Theme> | - | The system prop for defining CSS overrides and additional styles. |
titleAccess | string | - | Provides a human-readable title for the element. |
viewBox | string | '0 0 24 24' | Allows you to redefine the coordinates inside an SVG element. |
Icon (Icon Fonts)
The Icon component displays an icon from any icon font that supports ligatures. Use this for icon fonts like Material Icons or Font Awesome.Basic Usage
First, you need to load the icon font in your project. For Material Icons, add this to your HTML:Color
Size
Font Awesome
You can use Icon with Font Awesome:Icon Props
| Prop | Type | Default | Description |
|---|---|---|---|
baseClassName | string | 'material-icons' | The base class applied to the icon. |
children | node | - | The name of the icon font ligature. |
classes | object | - | Override or extend the styles applied to the component. |
color | 'inherit' | 'action' | 'disabled' | 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning' | 'inherit' | The color of the component. |
fontSize | 'inherit' | 'large' | 'medium' | 'small' | 'medium' | The fontSize applied to the icon. Defaults to 24px. |
sx | SxProps<Theme> | - | The system prop for defining CSS overrides and additional styles. |
Material Icons
The@mui/icons-material package includes over 2,100 official Material Icons converted to SvgIcon components.
Installation
Usage
Browse the icons at mui.com/material-ui/material-icons/. Search for an icon and copy the import statement.Icon Variants
Material Icons are available in five variants:- Filled (default) -
@mui/icons-material/Home - Outlined -
@mui/icons-material/HomeOutlined - Rounded -
@mui/icons-material/HomeRounded - Two-tone -
@mui/icons-material/HomeTwoTone - Sharp -
@mui/icons-material/HomeSharp
Color and Size
Material Icon components inherit all SvgIcon props:Creating Custom SVG Icons
If you need a custom SVG icon that isn’t available in Material Icons:SVG Icon from Image File
You can import SVG files and use them as React components:CSS Classes
SvgIcon Classes
.MuiSvgIcon-root- Styles applied to the root element..MuiSvgIcon-colorPrimary- Styles applied ifcolor="primary"..MuiSvgIcon-colorSecondary- Styles applied ifcolor="secondary"..MuiSvgIcon-colorAction- Styles applied ifcolor="action"..MuiSvgIcon-colorError- Styles applied ifcolor="error"..MuiSvgIcon-colorDisabled- Styles applied ifcolor="disabled"..MuiSvgIcon-fontSizeInherit- Styles applied iffontSize="inherit"..MuiSvgIcon-fontSizeSmall- Styles applied iffontSize="small"..MuiSvgIcon-fontSizeMedium- Styles applied iffontSize="medium"..MuiSvgIcon-fontSizeLarge- Styles applied iffontSize="large".
Icon Classes
.MuiIcon-root- Styles applied to the root element..MuiIcon-colorPrimary- Styles applied ifcolor="primary"..MuiIcon-colorSecondary- Styles applied ifcolor="secondary"..MuiIcon-colorAction- Styles applied ifcolor="action"..MuiIcon-colorError- Styles applied ifcolor="error"..MuiIcon-colorDisabled- Styles applied ifcolor="disabled"..MuiIcon-fontSizeInherit- Styles applied iffontSize="inherit"..MuiIcon-fontSizeSmall- Styles applied iffontSize="small"..MuiIcon-fontSizeMedium- Styles applied iffontSize="medium"..MuiIcon-fontSizeLarge- Styles applied iffontSize="large".
Accessibility
Decorative Icons
If the icon is purely decorative and doesn’t convey meaning, usearia-hidden="true":
Semantic Icons
If the icon has semantic meaning, provide a text alternative usingtitleAccess:
<title> element inside the SVG that can be accessed by assistive technologies.