Icon component

The kit:icon component is a sizing and accessibility wrapper for icons. It supports three rendering modes: SVG component via children, image via src, or CSS icon font via name.

icon.svelte

kit:icon renders as an <i> by default. It sets a consistent font-size equal to the current size token, which becomes the width and height of the inner SVG or image. Child SVG components (e.g. lucide-svelte) inherit this size automatically.

All icons are decorative by default (aria-hidden="true"). Set decorative={false} with a label or alt to expose them to assistive technologies.

Examples of icon

size

When no size is set, the icon inherits the font-size of its parent useful inside buttons and chips where the size is already controlled.

  • size: 'xs' | 'sm' | 'md' | 'lg' | 'xl' = inherits
icon.svelte

color

Pass a CSS color value to color. It sets both color and --kit-icon-color so the icon and mask mode both pick it up.

  • color: string = ''
icon.svelte

src image icons

Pass an image URL to src. For SVG sources, colorMode="mask" applies currentColor via CSS mask useful for single-color icons that need to follow the theme.

  • src: string = ''
  • colorMode: 'auto' | 'mask' | 'filter' | 'none' = 'auto'
  • imgFilter: string = ''
icon.svelte

Accessibility

By default icons are hidden from assistive technologies (decorative={true}, aria-hidden="true"). Set decorative={false} and provide label (or alt for image icons) when the icon carries meaning on its own.

  • decorative: boolean = true
  • label: string | undefined = undefined
  • alt: string | undefined = undefined

Without preprocess Lapikit

If you aren’t using the Lapikit preprocessor in svelte.config.js, import the components directly:

API Reference

kit:icon

propstypedescriptiondefault
isstringHTML element to render.'i'
sizeenum'xs''sm''md''lg''xl'Icon size token. Inherits from context when unset.
srcstringImage URL. Used instead of children.
namestringCSS class name for icon fonts.
iconstringAlias treated as src if it contains /, else name.
colorstringColor applied to the icon and mask.
colorModeenum'auto''mask''filter''none'How color is applied to image icons.'auto'
imgFilterstringCSS filter value used in filter mode.
decorativebooleanHides from assistive tech when true.true
labelstringAccessible label when decorative={false}.
altstringAlt text for image icons.''
loadingenum'eager''lazy'Image loading strategy.'eager'
decodingenum'sync''async''auto'Image decoding hint.'async'
childrenSnippetSVG icon component (e.g. from lucide-svelte).

Add kit:icon to your Buttons, Cards or Chips to visually guide your users.