List component
The kit:list and kit:list-item components render structured vertical lists. Items are interactive automatically when onclick is attached or href is set.
<script lang="ts">
import { Inbox, Send, Archive, Trash2, Star } from 'lucide-svelte';
const items = [
{ icon: Inbox, label: 'Inbox', count: 12 },
{ icon: Star, label: 'Starred', count: 3 },
{ icon: Send, label: 'Sent' },
{ icon: Archive, label: 'Archive' },
{ icon: Trash2, label: 'Trash' }
];
let active = $state('Inbox');
</script>
<kit:list style="max-width: 240px;">
{#each items as item (item.icon)}
<kit:list-item is="button" active={active === item.label} onclick={() => (active = item.label)}>
{#snippet prepend()}
{@const Icon = item.icon}
<kit:icon><Icon /></kit:icon>
{/snippet}
{item.label}
{#if item.count}
{#snippet append()}
<kit:chip variant="filled" size="xs" labelStyle>{item.count}</kit:chip>
{/snippet}
{/if}
</kit:list-item>
{/each}
</kit:list>
kit:list is a layout container that sets size tokens consumed by its kit:list-item children. kit:list-item detects its tag automatically: it renders as <a> when href is set, <button> when an onclick is attached, or <div> otherwise.
Examples of list
Variants
The variant and the color of the list apply to all its items. A kit:list-item can override the color with its own color.
filled (default): surface background (
--kit-color-surface-2), or thecolorwith a contrasted text.tonal: light tint of the color, text in the color.
outline: transparent background with a border on each item.
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'color:
string | false=undefined
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem;">
{#each ['filled', 'tonal', 'outline', 'surface', 'text', 'plain'] as variant (variant)}
<kit:list {variant} color="accent">
<kit:list-item is="button">{variant}</kit:list-item>
<kit:list-item is="button" active>Item two</kit:list-item>
<kit:list-item is="button">Item three</kit:list-item>
</kit:list>
{/each}
</div>
prepend and append
kit:list-item supports prepend and append snippets for icons, avatars, badges, or any inline content.
- prepend:
Snippet | undefined=undefined - append:
Snippet | undefined=undefined
<script lang="ts">
import { User, Mail, Phone, ChevronRight } from 'lucide-svelte';
</script>
<kit:list style="max-width: 280px;">
<kit:list-item is="button">
{#snippet prepend()}<kit:icon><User /></kit:icon>{/snippet}
Profile
{#snippet append()}<kit:icon size="sm"><ChevronRight /></kit:icon>{/snippet}
</kit:list-item>
<kit:list-item is="button">
{#snippet prepend()}<kit:icon><Mail /></kit:icon>{/snippet}
Email
{#snippet append()}<kit:icon size="sm"><ChevronRight /></kit:icon>{/snippet}
</kit:list-item>
<kit:list-item is="button">
{#snippet prepend()}<kit:icon><Phone /></kit:icon>{/snippet}
Phone
{#snippet append()}<kit:icon size="sm"><ChevronRight /></kit:icon>{/snippet}
</kit:list-item>
</kit:list>
nav
Add nav to kit:list (and is="nav") for a navigation list. This increases padding and sets role="navigation" on the container.
- nav:
boolean=false
<kit:list is="nav" nav style="max-width: 200px;">
<kit:list-item href="/docs">Documentation</kit:list-item>
<kit:list-item href="/docs/components" active>Components</kit:list-item>
<kit:list-item href="/docs/hooks">Hooks</kit:list-item>
<kit:list-item href="/docs/hooks" disabled>Changelog</kit:list-item>
</kit:list>
Without preprocess Lapikit
If you aren’t using the Lapikit preprocessor in svelte.config.js, import the components directly:
import { List, ListItem } from 'lapikit/components';API Reference
kit:list
| props | type | description | default |
|---|---|---|---|
| ref $bindable | HTMLElement | Bindable reference to the rendered DOM element. | null |
| is | enum'div''nav''ul' | HTML element to render. | 'div' |
| class | string | array | object | Classes of the list, with the rules of Svelte (clsx). | |
| style | string | Inline style of the list. | |
| s-class | string | array | object | Classes of the list, merged with class. | |
| s-style | object | Inline style as an object of property / value pairs. | |
| variant | enum'filled''tonal''outline''surface''text''plain' | Visual style of the items. | 'filled' |
| size | enum'xs''sm''md''lg''xl' | Item height, padding, gap and font size (in rem). | 'md' |
| density | enum'dense''compact''default''comfortable''spacious' | Item height and padding, from -4px to +4px. | 'default' |
| rounded | enum0'xs''sm''md''lg''xl''full' | Border radius on list items children. | 'md' |
| nav | boolean | Navigation mode more padding, role="navigation". | false |
| color | string | false | Color of all the items, its use depends on the variant. | |
| children | Snippet | List items. |
kit:list-item
| props | type | description | default |
|---|---|---|---|
| ref $bindable | HTMLElement | Bindable reference to the rendered DOM element. | null |
| is | enum'div''a''button''li' | HTML element. Overridden by href or onclick. | 'div' |
| class | string | array | object | Classes of the item, with the rules of Svelte (clsx). | |
| style | string | Inline style of the item. | |
| s-class | string | array | object | Classes of the item, merged with class. | |
| s-style | object | Inline style as an object of property / value pairs. | |
| href | string | Renders as <a>. Cleared when disabled. | |
| active | boolean | Applies the active color. | false |
| disabled | boolean | Dims and blocks interaction. | false |
| noRipple | boolean | Disables the ripple animation. | false |
| interactive | boolean | undefined | undefined detects (<a>, <button>, onclick), true forces, false disables the visual feedback. | undefined |
| color | string | false | { base?, active? } | Color of the item, overrides the color of the list. | |
| prepend | Snippet | Content before the label. | |
| append | Snippet | Content after the label. | |
| children | Snippet | Item label. |
A well-structured kit:list can easily be enriched with Separators or elements in a Card.
