A Svelte library for displaying Google Material Symbols as SVG icons.
npm install @noughts/svelte-material-symbols
<script>
import { MaterialSymbol } from '@noughts/svelte-material-symbols';
</script>
<!-- Basic usage -->
<MaterialSymbol icon="home" />
<!-- Customized icon -->
<MaterialSymbol icon="star" fill color="gold" size={32} />
| Property | Type | Default | Description |
|---|---|---|---|
icon |
string |
Required | Icon name to display |
fill |
boolean |
false |
Whether to fill the icon |
weight |
number |
400 |
Font weight (200-700) |
grade |
-25 | 0 | 200 |
0 |
Grade adjustment |
opticalSize |
20 | 24 | 40 | 48 |
24 |
Optical size |
color |
string |
"#000000" |
Color in light mode |
darkColor |
string |
value of color |
Color in dark mode |
opacity |
number |
1 |
Opacity (0-1) |
size |
number | undefined |
undefined |
Size in pixels (defaults to 1em if unspecified) |
<MaterialSymbol icon="check_circle" />
<MaterialSymbol icon="favorite" fill />
<MaterialSymbol icon="settings" weight={700} />
<MaterialSymbol icon="star" color="orange" size={48} />
<MaterialSymbol icon="error" color="red" size={24} />
<!-- Black in light mode, white in dark mode -->
<MaterialSymbol icon="brightness_6" color="#333333" darkColor="#eeeeee" />
<button>
<MaterialSymbol icon="add" />
Add Item
</button>
<div class="rating">
<MaterialSymbol icon="star" fill color="gold" />
<MaterialSymbol icon="star" fill color="gold" />
<MaterialSymbol icon="star" fill color="gold" />
<MaterialSymbol icon="star" color="gold" />
<MaterialSymbol icon="star" color="gold" />
</div>
All icons provided by Google Material Symbols are available. You can find icon names on the Material Symbols official site.
Examples: home, star, favorite, settings, menu, search, add, delete, edit, check, close, etc.
This library loads SVG files directly from the official Google Material Design Icons GitHub repository. It uses CSS mask to colorize SVGs with background colors, enabling lightweight and flexible color changes.
Uses the prefers-color-scheme: dark media query to automatically detect system dark mode settings and apply appropriate colors.
npm run dev
npm run package
npm run build
This project is released under the MIT License.