Usage Guide
Learn how to install and use @material-symbols-svg/react in your project.
Installation
Install the package using your preferred package manager:
Basic Usage
Import icons by weight and style:
Preview:
Icon Styles
Material Symbols come in three styles:
Outlined (Default)
Rounded
Sharp
Icon Weights
Icons are available in 7 different weights (100-700):
Preview:
Icon Size
Control icon size using the size
prop:
Preview:
Icon Color
Using color prop
Preview:
Using CSS classes
Preview:
Using CSS custom properties
Next.js Configuration
⚠️ Important for Next.js Users
Without proper configuration, Next.js development mode will load all icons, consuming significant memory and slowing down your development experience.
Add the following configuration to your next.config.js
or next.config.ts
. Include only the specific style/weight combinations you use in your project:
Basic Configuration (for outlined/w400 only)
Advanced Configuration (variant-specific)
If you use specific styles and weights, include them explicitly:
Example: If you import from @material-symbols-svg/react-sharp/w600
, you must include '@material-symbols-svg/react-sharp'
in the array.
Complete Configuration (all weights and styles)
For projects using multiple weights and styles, include all variants:
💡 Configuration Tips
- • Only include the weight variants you actually use in your project
- • If you import from
@material-symbols-svg/react/w600
, include'@material-symbols-svg/react'
in the array - • The base package is required even when importing specific weights
- • Remove unused weight variants to keep your configuration clean
Benefits of optimizePackageImports
- Faster development:Only loads the icons you actually import
- Lower memory usage:Prevents loading thousands of unused icons
- Better performance:Reduces bundle size and improves hot reload speed
- Tree shaking:Automatically removes unused icons from production builds
Without optimizePackageImports
❌ Next.js will load all 46,000+ icon variants per package in development mode, which can consume several GB of memory and significantly slow down your development server.
With optimizePackageImports
✅ Next.js will only load the icons you actually import, keeping memory usage low and development fast.
Advanced Usage
Individual Icon Imports
Each individual icon file exports multiple weight and fill variants:
Preview:
📝 Individual Icon Structure
Each icon file exports 14 variants: 7 regular weights (W100-W700) and 7 filled weights (FillW100-FillW700). This gives you precise control over which specific variant you import.
Benefits of Individual Imports
- Smaller bundle size:Only the specific variants you use are included
- Better tree shaking:More granular control over what gets bundled
- Clear dependencies:Explicit about which weight and fill variants you're using
Custom Styling
Preview:
SVG Attributes Control
Each icon component accepts standard SVG attributes and allows you to override or add custom attributes:
Default Attributes
width/height
:size prop value
(default: 24)viewBox
: "0 -960 960 960
" (fixed)fill
: "none
" (SVG element)xmlns
: "http://www.w3.org/2000/svg
" (fixed)aria-hidden
: "true
" (accessibility)
Override and Add Attributes
💡 Accessibility Tips
- Keep
aria-hidden="true"
for decorative icons - Add
aria-label
for meaningful icons - Use appropriate
role
for interactive icons