Skip to content
CodeAtlas UI

Display

Chip

Compact element for tags, filters and status labels, with icons, color variants, selection and deletion.

<script>
  import { Chip, StatusChip } from "@codeatlasdev/ui";
</script>

<Chip label="Design" variant="brand" deletable ondelete={remove} />
<StatusChip status="success" label="Active" />

A chip becomes a keyboard-focusable toggle button when onclick is set: Enter and Space activate it and aria-pressed follows selected. StatusChip is a separate, non-interactive component for dot + label statuses.

Basic

Design System Svelte 5 Bits UI
Code
svelte
<script lang="ts">
  import { Chip } from '@codeatlasdev/ui';
</script>

<Chip label="Design System" />
<Chip label="Svelte 5" />
<Chip label="Bits UI" />

Variants and size

Semantic variants and the compact `sm` size.

Default Brand Success Warning Error Info Small
Code
svelte
<script lang="ts">
  import { Chip } from '@codeatlasdev/ui';
</script>

<Chip label="Default" />
<Chip label="Brand" variant="brand" />
<Chip label="Success" variant="success" />
<Chip label="Warning" variant="warning" />
<Chip label="Error" variant="error" />
<Chip label="Info" variant="info" />
<Chip label="Small" size="sm" />

With icons

Pass any Lucide icon component to `icon`.

Featured Boosted Tagged
Code
svelte
<script lang="ts">
  import { Chip } from '@codeatlasdev/ui';
  import { Tag, Star, Zap } from '@lucide/svelte';
</script>

<Chip label="Featured" icon={Star} />
<Chip label="Boosted" icon={Zap} />
<Chip label="Tagged" icon={Tag} />

Selectable

Set `onclick` to make the chip a toggle.

Filter A Filter B
Code
svelte
<script lang="ts">
  import { Chip } from '@codeatlasdev/ui';

  let a = $state(false);
  let b = $state(true);
</script>

<Chip label="Filter A" selected={a} onclick={() => (a = !a)} />
<Chip label="Filter B" selected={b} onclick={() => (b = !b)} />

Deletable

Click the × button to remove a tag.

Design Svelte Glass
Code
svelte
<script lang="ts">
  import { Chip } from '@codeatlasdev/ui';

  const initial = ['Design', 'Svelte', 'Glass'];
  let tags = $state([...initial]);
</script>

{#each tags as tag (tag)}
  <Chip label={tag} deletable ondelete={() => (tags = tags.filter((t) => t !== tag))} />
{/each}
{#if tags.length === 0}
  <button class="reset" type="button" onclick={() => (tags = [...initial])}>Reset tags</button>
{/if}

<style>
  .reset {
    font: inherit;
    font-size: var(--ca-font-size-caption);
    color: var(--ca-brand-text);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
  }
</style>

StatusChip

Semantic status indicators with dot and label.

Active Pending Failed Scheduled Draft
Code
svelte
<script lang="ts">
  import { StatusChip } from '@codeatlasdev/ui';
</script>

<StatusChip status="success" label="Active" />
<StatusChip status="warning" label="Pending" />
<StatusChip status="error" label="Failed" />
<StatusChip status="info" label="Scheduled" />
<StatusChip status="neutral" label="Draft" />

Chip props

PropTypeDefaultDescription
labelstring–Text content of the chip. Required.
iconComponentundefinedIcon component rendered before the label.
variant'default' | 'success' | 'error' | 'warning' | 'info' | 'brand''default'Color variant.
size'sm' | 'md''md'Chip size.
selectedbooleanfalseSelected visual state, exposed as `aria-pressed` on interactive chips.
deletablebooleanfalseShows a × remove button.
onclick() => voidundefinedMakes the chip interactive (button role, focusable).
ondelete() => voidundefinedCalled when the × button is clicked.
classstring''Extra class names.

StatusChip props

PropTypeDefaultDescription
status'success' | 'warning' | 'error' | 'info' | 'neutral'–Semantic status. Required.
labelstring–Text shown next to the dot. Required.
classstring''Extra class names.