Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8
Carbon Design System SVG pictograms as Svelte components
License
carbon-design-system/carbon-pictograms-svelte
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Carbon Design System SVG pictograms as Svelte components.
This zero dependency library buildsCarbon Design System pictograms as Svelte components. Although best paired withcarbon-components-svelte, this library can be consumed standalone.
Try it in theSvelte REPL.
# npmnpm i carbon-pictograms-svelte# pnpmpnpm i carbon-pictograms-svelte# Yarnyarn add carbon-pictograms-svelte# Bunbun add carbon-pictograms-svelte
Import the icon from thecarbon-pictograms-svelte/lib folder. See thePictogram Index for a list of supported pictograms.
<script>importAirplanefrom"carbon-pictograms-svelte/lib/Airplane.svelte";</script><Airplane />
Tip
UseoptimizeImports fromcarbon-preprocess-svelte to speed up development times.
Due to the size of the library, importing directly from the barrel file may result in slow development times, since the entire barrel file is imported (thousands of pictograms).
optimizeImports is a Svelte preprocessor that optimizes import paths from Carbon Svelte libraries. It enables you to use the barrel file import syntax without importing the entire library.
For example, the following is automatically re-written byoptimizeImports:
- import { Airplane } from "carbon-pictograms-svelte";+ import Airplane from "carbon-pictograms-svelte/lib/Airplane.svelte";
This offers the best of both worlds:
- Concise import syntax
- Fast development times (only the icons you need are imported)
All props are optional.
| Name | Type | Default value |
|---|---|---|
| title | string | undefined |
$$restProps are forwarded to thesvg element.
You can usefill to customize the color or pass any other validsvg attribute to the component.
<Airplanefill="red"class="icon" />
<Airplanearia-label="Airplane" />
<labelid="transportation">Transportation</label><Airplanearia-labelledby="transportation" />
<Airplanetabindex={0} />
This library offers TypeScript support for Svelte 4 and Svelte 5.
For Svelte 3 compatibility, usecarbon-pictograms-svelte@12.12.0.
For convenience, aCarbonPictogramProps type is exported from the library.
<scriptlang="ts">importAirplanefrom"carbon-pictograms-svelte/lib/Airplane.svelte";importtype {CarbonPictogramProps }from"carbon-pictograms-svelte";const props:CarbonPictogramProps= { title:"Airplane", };</script><Airplane {...props} />
About
Carbon Design System SVG pictograms as Svelte components
Topics
Resources
License
Code of conduct
Contributing
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Contributors5
Uh oh!
There was an error while loading.Please reload this page.