metonym / svelte-codicons

VS Code Codicons as Svelte components

Home Page:https://metonym.github.io/svelte-codicons

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

svelte-codicons

NPM

VS Code Codicons as Svelte components.

This zero-dependency library uses svelvg to convert SVG files from the @vscode/codicons into Svelte components.

Try it in the Svelte REPL.


Installation

# Yarn
yarn add -D svelte-codicons

# npm
npm i -D svelte-codicons

# pnpm
pnpm i -D svelte-codicons

Usage

Basic

<script>
  import { Add, Calendar, Edit } from "svelte-codicons";
</script>

<Add />
<Calendar />
<Edit />

Refer to ICON_INDEX.md for a list of supported icons.

Direct import

Use the direct import for faster compiling during development.

<script>
  import Add from "svelte-codicons/lib/Add.svelte";
</script>

Using svelte:component

<script>
  import * as icons from "svelte-codicons";
</script>

{#each Object.entries(icons) as [icon, component]}
  <div>
    <svelte:component this={component} />
    {icon}
  </div>
{/each}

Custom size

$$restProps are forwarded to the svg element.

Use the width and height attributes to customize the icon size. The default is 16px.

<Add width={36} height={36} />

Custom color

Use the fill attribute to specify a custom color.

<Add fill="red" />

License

MIT

vscode-codicons is licensed as CC-BY-4.0.

About

VS Code Codicons as Svelte components

https://metonym.github.io/svelte-codicons

License:MIT License


Languages

Language:JavaScript 76.9%Language:Svelte 23.1%