Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

carbon-pictograms-svelte

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

carbon-pictograms-svelte

Carbon Design System SVG pictograms as Svelte components

  • 10.16.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.9K
increased by275.93%
Maintainers
1
Weekly downloads
 
Created
Source

carbon-pictograms-svelte

NPM carbon-pictograms-svelte Travis CI build status

Carbon Design System SVG pictograms as Svelte components.

This zero dependency library builds Carbon Design System pictograms as Svelte components. Although best paired with carbon-components-svelte, this library can be consumed standalone.

Preview

Getting Started

carbon-pictograms-svelte can be installed using yarn or npm.

yarn add -D carbon-pictograms-svelte
# OR
npm i -D carbon-pictograms-svelte

Usage

Base Import

<script>
  import { Airplane } from "carbon-pictograms-svelte";
</script>

<Airplane />

Import pictograms directly for faster compiling.

import Airplane from "carbon-pictograms-svelte/lib/Airplane";

Note: Even if using the base import method, an application bundler like Rollup or Webpack should treeshake unused pictograms from the production build.

Import Path Pattern
import Pictogram from "carbon-pictograms-svelte/lib/<ModuleName>";

Refer to PICTOGRAM_INDEX.md for a list of available pictograms.

API

Props

All props are optional.

NameValue
idstring
aria-labelstring
aria-labelledbystring
tabindexstring
titlestring
focusableboolean (default: false)
classstring
stylestring
fillstring (default: "#161616"
strokestring (default "currentColor")
widthstring (default: "48")
heightstring (default: "48")
title as a Slot

title can be passed as a prop or through the slot as an element.

<Airplane title="Airplane" />
<!-- OR -->
<Airplane>
  <title>Airplane</title>
</Airplane>

Forwarded Events

Event directives are forwarded to the SVG element.

<Airplane
  on:click="{() => {}}"
  on:mouseenter="{() => {}}"
  on:mouseover="{() => {}}"
  on:mouseleave="{() => {}}"
  on:keyup="{() => {}}"
  on:keydown="{() => {}}"
/>

data-carbon-pictogram selector

Each pictogram embeds its module name in the data-carbon-pictogram selector for querying. This may be useful for automated testing in a headless browser.

<svg data-carbon-pictogram="Airplane">...</svg>
// selects all carbon pictograms
document.querySelectorAll("[data-carbon-pictogram]");

// selects all `Airplane` pictograms
document.querySelectorAll('[data-carbon-pictogram="Airplane"]');

Recipes

Custom Stroke Color

Customize the stroke color through the stroke proop or by defining a global class.

stroke prop
<Airplane stroke="blue" />
Global class
<style>
  :global(svg.custom-class) {
    stroke: blue;
  }
</style>

<Airplane class="custom-class" />

Labelled

<Airplane aria-label="Airplane" />

Labelled with Focus

<Airplane aria-label="Airplane" tabindex="0" />

Labelled by

<label id="transportation">Transportation</label>

<Airplane aria-labelledby="transportation" />

Examples

Changelog

Contributing

License

Apache-2.0

Keywords

FAQs

Package last updated on 09 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc