Components

Chip component

The kit:chip component displays small interactive labels, perfect for representing status, categories, filters or actions. Compact, stylable and highly flexible, it can be clicked, disabled, loaded, closed or enriched with snippets. It supports different variants, states, densities and sizes, to suit all UI contexts. It can be used alone, in groups, or as the basis for a tag or filter system.

chip.svelte
<script lang="ts">
	const filters = ['All', 'Design', 'Engineering', 'Product', 'Marketing'];
	let active = $state('All');
</script>

<div style="display: flex; gap: 0.5rem; flex-wrap: wrap;">
	{#each filters as f (f)}
		<kit:chip
			is="button"
			variant={active === f ? 'filled' : 'outline'}
			onclick={() => (active = f)}
		>
			{f}
		</kit:chip>
	{/each}
</div>

kit:chip renders as a <div> by default. It becomes interactive automatically when onclick is attached, href is set, or is="button". It is a pill by default (rounded="full").

Examples of chip

Variants

Variants adapt the overall appearance of the chip to graphic needs.

  • filled (default): surface background (--kit-color-surface-2), or the color with a contrasted text.

  • tonal: light tint of the color, text in the color.

  • outline: transparent background with a border.

  • surface: very light tint of the color with a soft border.

  • text: transparent background, text in the color.

  • plain: like text, but hover and pressed only change the text color, never the background.

  • variant: 'filled' | 'tonal' | 'outline' | 'surface' | 'text' | 'plain' = 'filled'

The border thickness of outline and surface is set by the global variable --kit-outline-weight (1px by default).

chip.svelte
<div style="display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;">
	{#each ['filled', 'tonal', 'outline', 'surface', 'text', 'plain'] as variant (variant)}
		<kit:chip {variant} color="accent">{variant}</kit:chip>
	{/each}
</div>

size

With size, adjust the chip’s height, padding, font size and the gap between the icon and the text. From compact tags to larger status indicators, this prop allows you to create chips that fit perfectly into different contexts.

  • size: 'xs' | 'sm' | 'md' | 'lg' | 'xl' = 'md'
sizeheightfont size
xs1.25rem (20px)0.6875rem (11px)
sm1.5rem (24px)0.75rem (12px)
md2rem (32px)--kit-font-xs (13px)
lg2.25rem (36px)--kit-font-sm (14px)
xl2.5rem (40px)--kit-font-md (15px)

The sizes are in rem: the chip grows with the font size set in the browser. The values in px are for the default size (16px).

chip.svelte
<div style="display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;">
	{#each ['xs', 'sm', 'md', 'lg', 'xl'] as size (size)}
		<kit:chip variant="outline" {size}>{size}</kit:chip>
	{/each}
</div>

Density

density adjusts the height and the horizontal padding, from -4px (dense) to +4px (spacious), without changing the font size.

  • density: 'dense' | 'compact' | 'default' | 'comfortable' | 'spacious' = 'default'
chip.svelte
<div style="display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;">
	{#each ['dense', 'compact', 'default', 'comfortable', 'spacious'] as density (density)}
		<kit:chip variant="outline" {density}>{density}</kit:chip>
	{/each}
</div>

Colors

color accepts a color of the palette (accent, success…) or any CSS color. With a palette color, the text color follows its on- color; otherwise a contrasted color is computed.

Pass an object to use another color when the chip is active, or false for no color, handy with a condition: color={isActive && 'accent'}.

  • color: string | false | { base?: string | false; active?: string | false } = undefined
chip.svelte
<script lang="ts">
	let selected = $state(false);
</script>

<div style="display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;">
	<kit:chip color="success">Palette</kit:chip>
	<kit:chip variant="tonal" color="#e11d48">Custom</kit:chip>
	<kit:chip
		variant="outline"
		color={{ base: 'accent', active: 'success' }}
		active={selected}
		onclick={() => (selected = !selected)}
	>
		{selected ? 'Selected' : 'Select'}
	</kit:chip>
	<kit:chip variant="tonal" color={selected && 'success'}>Follows the selection</kit:chip>
</div>

Interactive

An interactive chip changes its background on hover and pressed, and shows a ripple on click.

  • interactive: boolean | undefined = undefined

  • undefined - detected: interactive when the chip renders as <a> or <button>, is an input, or has an onclick, onkeydown or onkeyup handler.

  • true - forced, without changing the element.

  • false - no visual feedback, the chip stays clickable.

chip.svelte
<div style="display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;">
	<kit:chip variant="outline">Static</kit:chip>
	<kit:chip variant="outline" onclick={() => alert('clicked')}>With onclick</kit:chip>
	<kit:chip variant="outline" href="/docs">As a link</kit:chip>
	<kit:chip variant="outline" interactive={false} onclick={() => alert('clicked')}>
		No feedback
	</kit:chip>
</div>

prepend and append snippets

Use prepend for an icon before the label, and append for an action typically a remove button.

  • prepend: Snippet | undefined = undefined
  • append: Snippet | undefined = undefined
chip.svelte
<script lang="ts">
	import { Tag, X, CircleCheck } from 'lucide-svelte';

	let tags = $state(['Svelte', 'TypeScript', 'CSS']);

	function remove(tag: string) {
		tags = tags.filter((t) => t !== tag);
	}
</script>

<div style="display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;">
	<kit:chip variant="outline">
		{#snippet prepend()}
			<kit:icon size="sm"><Tag /></kit:icon>
		{/snippet}
		Label
	</kit:chip>

	<kit:chip variant="filled">
		{#snippet prepend()}
			<kit:icon size="sm"><CircleCheck /></kit:icon>
		{/snippet}
		Verified
	</kit:chip>

	{#each tags as tag (tag)}
		<kit:chip variant="outline">
			{tag}
			{#snippet append()}
				<kit:btn icon variant="text" density="compact" size="xs" onclick={() => remove(tag)}>
					<kit:icon size="sm"><X /></kit:icon>
				</kit:btn>
			{/snippet}
		</kit:chip>
	{/each}
</div>

States

disabled dims (--kit-disabled-opacity) and blocks interaction. readonly blocks interaction without the dim. active applies the active color, useful for toggled filter chips. While loading, aria-busy is set.

  • active: boolean = false
  • disabled: boolean = false
  • readonly: boolean = false
chip.svelte
<div style="display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;">
	<kit:chip variant="outline" active>Active</kit:chip>
	<kit:chip variant="outline" disabled>Disabled</kit:chip>
	<kit:chip variant="outline" readonly>Readonly</kit:chip>
	<kit:chip variant="filled" disabled>Disabled filled</kit:chip>
</div>

labelStyle

labelStyle applies uppercase, bold, and slight letter-spacing suited for category or status badges.

  • labelStyle: boolean = false
chip.svelte
<div style="display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;">
	<kit:chip variant="filled" labelStyle>New</kit:chip>
	<kit:chip variant="outline" labelStyle>Beta</kit:chip>
	<kit:chip variant="outline" labelStyle>Deprecated</kit:chip>
	<kit:chip variant="filled" labelStyle size="sm">Pro</kit:chip>
</div>

As an input

Add input (or is="input") to render a native <input> styled as a chip, inside a wrapper. A checkbox or a radio is wrapped in a <label>: the whole chip toggles the input, and it takes the active style while checked. Perfect for filters.

  • input: boolean = false
  • type: 'button' | 'submit' | 'reset' | 'checkbox' | 'radio' = 'button'
  • label: string | undefined = undefined, the text of a checkbox or a radio (value when empty)
  • value: string | number | boolean | undefined = undefined
  • checked: boolean | undefined = undefined

The other attributes (name, onchange…) go on the <input>, so the chip works in a form like a native input.

chip.svelte
<script lang="ts">
	const options = ['Design', 'Engineering', 'Product'];
	let filters = $state<string[]>(['Design']);
	let sort = $state('recent');

	function toggle(option: string) {
		filters = filters.includes(option)
			? filters.filter((value) => value !== option)
			: [...filters, option];
	}
</script>

<div style="display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;">
	{#each options as option (option)}
		<kit:chip
			input
			type="checkbox"
			label={option}
			variant="outline"
			checked={filters.includes(option)}
			onchange={() => toggle(option)}
		/>
	{/each}

	{#each ['recent', 'popular'] as value (value)}
		<kit:chip
			input
			type="radio"
			name="sort"
			{value}
			label={value}
			variant="tonal"
			color="accent"
			checked={sort === value}
			onchange={() => (sort = value)}
		/>
	{/each}
</div>

<p>Filters: {filters.join(', ') || 'none'}, sort: {sort}</p>

Without preprocess Lapikit

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

import { Chip } from 'lapikit/components';

API Reference

kit:chip

propstypedescriptiondefault
ref $bindableHTMLElementBindable reference to the rendered DOM element.null
isenum'div''a''button''input'HTML element. Overridden by href or event handlers; 'input' is the same as input.'div'
classstring | array | objectClasses of the chip, with the rules of Svelte (clsx).
stylestringInline style of the chip.
s-classstring | array | objectClasses of the chip, merged with class.
s-styleobjectInline style as an object of property / value pairs.
variantenum'filled''tonal''outline''surface''text''plain'Visual style.'filled'
sizeenum'xs''sm''md''lg''xl'Height, padding, font size and gap.'md'
densityenum'dense''compact''default''comfortable''spacious'Height and horizontal padding.'default'
interactiveboolean | undefinedundefined detects, true forces, false disables the visual feedback.undefined
hrefstringRenders as <a>. Cleared when disabled or readonly, the link leaves the keyboard navigation.
typeenum'button''submit''reset''checkbox''radio'Type of the button or of the input.
inputbooleanRenders an <input> in a wrapper (a <label> for a checkbox or a radio).
valuestring | number | booleanValue of the input.
checkedbooleanChecked state of a checkbox or a radio input.
labelstringText of the input, value when empty.
roundedenum0'xs''sm''md''lg''xl''full'Border radius.'full'
activebooleanApplies the active color.false
disabledbooleanDims and blocks all interaction.false
readonlybooleanBlocks interaction without disabled styling.false
labelStylebooleanUppercase, bold, letter-spacing for badges and categories.false
loadingbooleanShows a spinner, hides content, sets aria-busy.
noRipplebooleanDisables the ripple animation on click.
prependSnippetContent before the label.
appendSnippetContent after the label.
loadSnippetCustom spinner content shown while loading.
childrenSnippetChip label.
colorstring | false | { base?, active? }Chip color, its use depends on the variant.
elevationElevationStateenum'0''1''2''3''4''5'Add shadow effect.

class: and style: directives also work on kit:chip with the Lapikit preprocessor, see Class and Style.

kit:chip are often used in a Toolbar or as a complement in a Card to structure information and List.