Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/carbon-design-system/carbon-pictograms-svelte
Carbon Design System SVG pictograms as Svelte components
https://github.com/carbon-design-system/carbon-pictograms-svelte
carbon carbon-design-system pictograms svelte svelte-component svg typescript-definitions
Last synced: 4 days ago
JSON representation
Carbon Design System SVG pictograms as Svelte components
- Host: GitHub
- URL: https://github.com/carbon-design-system/carbon-pictograms-svelte
- Owner: carbon-design-system
- License: apache-2.0
- Created: 2020-04-06T23:41:02.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2025-01-26T22:57:52.000Z (19 days ago)
- Last Synced: 2025-02-03T07:48:37.948Z (11 days ago)
- Topics: carbon, carbon-design-system, pictograms, svelte, svelte-component, svg, typescript-definitions
- Language: TypeScript
- Homepage: https://carbon-pictograms-svelte.onrender.com
- Size: 4.82 MB
- Stars: 122
- Watchers: 7
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
- awesome-starred - carbon-design-system/carbon-pictograms-svelte - Carbon Design System SVG pictograms as Svelte components (svelte)
README
# carbon-pictograms-svelte
[![NPM][npm]][npm-url]
![GitHub](https://img.shields.io/github/license/ibm/carbon-pictograms-svelte?color=262626&style=for-the-badge)
![npm downloads to date](https://img.shields.io/npm/dt/carbon-pictograms-svelte?color=262626&style=for-the-badge)> [Carbon Design System](https://github.com/carbon-design-system) SVG pictograms as Svelte components.
This zero dependency library builds [Carbon Design System pictograms](https://www.carbondesignsystem.com/guidelines/pictograms/library) as Svelte components. Although best paired with [carbon-components-svelte](https://github.com/IBM/carbon-components-svelte), this library can be consumed standalone.
Try it in the [Svelte REPL](https://svelte.dev/repl/88b99674d0f24a3a8948d3760f8ba999).
## [Preview](https://carbon-pictograms-svelte.onrender.com/) · [Pictogram Index](PICTOGRAM_INDEX.md)
## Installation
```sh
# npm
npm i carbon-pictograms-svelte# pnpm
pnpm i carbon-pictograms-svelte# Yarn
yarn add carbon-pictograms-svelte# Bun
bun add carbon-pictograms-svelte
```## Usage
### Direct Import
Import the icon from the `carbon-pictograms-svelte/lib` folder. See the [Pictogram Index](PICTOGRAM_INDEX.md) for a list of supported pictograms.
```svelte
import Airplane from "carbon-pictograms-svelte/lib/Airplane.svelte";
```
### Base Import with Preprocessor
> [!TIP]
> Use [optimizeImports](https://github.com/carbon-design-system/carbon-preprocess-svelte#optimizeimports) from [carbon-preprocess-svelte](https://github.com/carbon-design-system/carbon-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](https://github.com/carbon-design-system/carbon-preprocess-svelte#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 by `optimizeImports`:
```diff
- 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.
| Name | Type | Default value |
| :---- | :------- | :------------ |
| title | `string` | `undefined` |### Custom props
`$$restProps` are forwarded to the `svg` element.
You can use `fill` to customize the color or pass any other valid `svg` attribute to the component.
```svelte
```
### Labelled
```svelte
```
### Labelled by
```svelte
Transportation```
### Focusable
```svelte
```
## TypeScript
This library offers TypeScript support for Svelte 4 and Svelte 5.
For Svelte 3 compatibility, use [`[email protected]`](https://github.com/carbon-design-system/carbon-pictograms-svelte/tree/v12.12.0).
For convenience, a `CarbonPictogramProps` type is exported from the library.
```svelte
import Airplane from "carbon-pictograms-svelte/lib/Airplane.svelte";
import type { CarbonPictogramProps } from "carbon-pictograms-svelte";const props: CarbonPictogramProps = {
title: "Airplane",
};```
## [Changelog](CHANGELOG.md)
## [Contributing](CONTRIBUTING.md)
## License
[Apache-2.0](LICENSE)
[npm]: https://img.shields.io/npm/v/carbon-pictograms-svelte.svg?color=262626&style=for-the-badge
[npm-url]: https://npmjs.com/package/carbon-pictograms-svelte