Skip to content
Sveltier
Mode
Components

Chip

A compact pill for filters that toggle, tags that can be removed, small actions and statuses.

Usage

A Chip is a tonal pill a small control tall. What it is depends on what you give it: plain, it is a label; with selected, a toggle; with onclick, a button; with href, a link.

1 of 4 transaction types shown.

EUR GBP JPY USD
Settled Pending Declined Scheduled

Filters

Bind selected and the chip becomes a toggle button that flips it when pressed. A selected chip is filled and shows a check, so the state does not rely on colour alone.

Filters.svelte
<script>
  import { Chip } from 'sveltier';
  let card = $state(true);
  let transfer = $state(false);
</script>

<Chip bind:selected={card}>Card</Chip>
<Chip bind:selected={transfer}>Transfer</Chip>

Removable tags

closable adds a close button that calls onclose. Name it for what it removes with closeLabel. A chip that is itself a button or a link cannot also be closable, since one control would sit inside another; put the action in a Button next to it.

Currencies.svelte
<script>
  import { Chip } from 'sveltier';
  let currencies = $state(['EUR', 'GBP', 'USD']);
</script>

{#each currencies as currency (currency)}
  <Chip
    closable
    closeLabel="Remove {currency}"
    onclose={() => (currencies = currencies.filter((c) => c !== currency))}
  >
    {currency}
  </Chip>
{/each}

Accessibility

  • A filter chip is a <button> with aria-pressed, pressed with Enter or Space.
  • The close button is its own button in the tab order, named by closeLabel.
  • A plain chip is text, not a control: it is read but not focused.

API

NameTypeDefaultDescription
variant'elevated' | 'flat' | 'tonal' | 'outlined' | 'text' | 'plain''tonal'Visual weight. A selected chip is flat.
size'xs' | 'sm' | 'md' | 'lg' | 'xl''sm'Height and text size.
density'compact' | 'default' | 'comfortable''default'Multiplies the height and padding, never the text.
colorColor'neutral'The colour the variant is painted with.
roundedboolean | 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full'trueCorner rounding. true keeps the pill.
disabledbooleanfalseA disabled chip cannot be pressed; a disabled link loses its href.
selectedboolean–Makes the chip a toggle button (aria-pressed) that flips it when pressed: a filter. Bindable. Shows a check while selected.
closablebooleanfalseAdds a button that removes the chip by calling onclose. Only for chips that are not themselves buttons or links.
closeLabelstring–The name of the close button, such as Remove Euro. Defaults to the locale's close.
onclose() => void–Called by the close button.
prependSnippet–Content before the label, usually an icon or an avatar.
appendSnippet–Content after the label.
childrenSnippet–The label.
classClassValue | null–Classes added after the component's own: a string, an array or an object.
refHTMLSpanElement | HTMLButtonElement | HTMLAnchorElement | null–The root element, bindable with bind:ref.