Navigation

v1.0.0
Frameworks

Svelte

Render dynamic or fixed optical drawings in Svelte.

On this page

#Dynamic icons

Svelte is a required peer dependency. Install Svelte 5 in your application and install @master/icons-svelte.

<script lang="ts">  import { SearchIcon } from '@master/icons-svelte';  let element = $state<SVGSVGElement>();</script><SearchIcon size={20} corner="rounded" label="Search" bind:ref={element} />

The dynamic entry includes all nine optical size and corner combinations, along with their supported stroke widths, for each imported icon. It shares the same geometry as the other frameworks and SVG. size selects the nearest optical drawing; corner defaults to soft.

#Fixed icons

<script lang="ts">  import { SearchIcon } from '@master/icons-svelte/16/soft';</script><button aria-label="Search"><SearchIcon /></button>

Fixed entries include only one optical size and corner style. Replace 16/soft with any combination of 16, 20, 24 and sharp, soft, rounded. Fixed components do not accept corner or opticalSize; size only scales the selected drawing.

#Framework behavior

Native .svelte sources are compiled by your application for the server and browser. Use Svelte 5 event props such as onclick. bind:ref exposes the SVG element; changing size or corner updates the drawing.

Unlabeled icons are decorative. Use label, aria-label or aria-labelledby for a meaningful icon, or label the enclosing button. See accessibility.

#Custom stroke width

Both entries accept strokeWidth, in native units and steps of 0.25. It selects redrawn geometry rather than changing the SVG stroke attribute.

<script lang="ts">  import { SearchIcon } from '@master/icons-svelte/24/soft';</script><SearchIcon size={48} strokeWidth={2} />

See stroke width for the range of each optical size and how widths are drawn.