Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Carbon Design System SVG pictograms as Svelte components

License

NotificationsYou must be signed in to change notification settings

carbon-design-system/carbon-pictograms-svelte

NPMGitHubnpm downloads to date

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.

Installation

# npmnpm i carbon-pictograms-svelte# pnpmpnpm i carbon-pictograms-svelte# Yarnyarn add carbon-pictograms-svelte# Bunbun add carbon-pictograms-svelte

Usage

Direct Import

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 />

Base Import with Preprocessor

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)

API

All props are optional.

NameTypeDefault value
titlestringundefined

Custom props

$$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" />

Labelled

<Airplanearia-label="Airplane" />

Labelled by

<labelid="transportation">Transportation</label><Airplanearia-labelledby="transportation" />

Focusable

<Airplanetabindex={0} />

TypeScript

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} />

License

Apache-2.0

Sponsor this project

 

Contributors5


[8]ページ先頭

©2009-2025 Movatter.jp