Listy
Virtual lists, grouping, sticky headings and jumps to posts.
When to use
Listy displays long lists with virtualization, groups and sticky headings. It is suitable for stream of posts, contacts and grouped results. For a set of columns and table operations, use Table; headers, loading and pagination around Listy is collected by the application.
Listy CSS Prefixes show global ConfigProvider.prefixCls and local prefixCls without resetting state. Listy is an independent component of the package. The prefix applies in raw and virtual modes, to groups and scrollbars. When changing the prefix, lines and scrolling are preserved; mode switching is shown separately.
Data and virtual window
items contains the source objects. rowKey is required: field name or stable key getter, without fallback to the index. itemRender — Svelte snippet with an object and its index in the original items.
| Problem | Setting | Example |
|---|---|---|
| Output a small set | items, rowKey, itemRender |
Short set |
| Limit the number of DOM lines | virtual, positive height |
Virtualization |
| Group and pin headings | group, sticky |
Groups |
| Show different heights | DOM measurement | Rich Content |
| Add data as you scroll | onScroll |
Loading |
Local virtual takes precedence over ConfigProvider.virtual. The window needs a positive height; without it or with height=0, all lines are displayed. Virtual mode measures the content after mount and recalculates the window when resized. Do not change rowKey when editing text: the key retains its identity and measurement results.
Groups and software scrolling
group.key calculates the group key, title-snippet gets this key and the source objects. Groups are collected throughout items in order of first appearance; itemRender preserves the original index of the entry. sticky sticks titles inside a scrollable area.
bind:ref provides scrollTo after mount. The method accepts a pixel offset, a top/left object, a record key, or a groupKey. align selects top/bottom/auto, offset adds indent. In normal mode, the target of a group is its section, in virtual mode it is the title line.
onScroll currentTarget is the root of a regular list or the holder of a virtual one. When loading, check the status of the request, the remainder of the scroll and the availability of the next portion. The example adds local data; network cancellation and error handling must be implemented by the application. The load button retains access to the same operation without hitting the exact end of the scroll.
Content, topic and restrictions
Empty does not appear automatically. Filtering, message without results, header/footer, loading and pagination are arranged around the list. Search shows such an empty state explicitly.
Rearrangement is the logic of the items owner. Sorting uses native drag for desktop and buttons; sensors and touch behavior of the external React dnd-kit are not added. rowHoverable and scrollWidth from Ant Design 6.7 are not yet available in the public Svelte API.
ConfigProvider.listy sets the general class/style and semantic settings of root/item/groupHeader. Callback gets initial props before defaults. The itemPaddingBlock/itemPaddingInline component design tokens are applied via theme.components.Listy; Semantic styles allow you to refine a specific area. An arbitrary prefixCls changes the classes, but does not generate the corresponding inline CSS.
The custom line markup is responsible for the available names, links, and buttons. Virtualization is not lookup: invisible entries may not be in the DOM. Don't pass off a list as a full-fledged listbox without a selection model and a keyboard.
Examples
Shortlist
items, required rowKey and custom row markup via itemRender.
<script lang="ts">
import { Listy } from '@woodger/antd';
const items = [
{ id: 1, title: "Documentation" }, { id: 2, title: "Examples" },
{ id: 3, title: "Versions" }, { id: 4, title: "Support" }
];
</script>
<Listy items={(items)} rowKey="id" role="list" aria-label={("Shortlist Listy")}>
{#snippet itemRender(item, index)}
<div role="listitem" aria-posinset={index + 1} aria-setsize={items.length}>
{(index + 1)}. {(item.title)}
</div>
{/snippet}
</Listy>
Virtual window
A thousand entries, positive height, virtual and transition to the key via ref.scrollTo.
<script lang="ts">
import { Button, Listy, type ListyRef } from '@woodger/antd';
const items = Array.from({ length: 1000 }, (_, index) => ({ key: index + 1 }));
let ref = $state<ListyRef>();
</script>
<style>
.controls {
display: flex;
flex-wrap: wrap;
gap: 12px;
margin-bottom: 16px;
}
</style>
<div class="controls">
<Button onclick={() => ref?.scrollTo({ key: 1000, align: 'bottom' })}>
{("To entry 1000")}
</Button>
<Button onclick={() => ref?.scrollTo(0)}>{("Back to top")}</Button>
</div>
<Listy items={(items)} rowKey="key" height={240} virtual bind:ref aria-label={("Virtual Listy")}>
{#snippet itemRender(item)}{("Record ")}{(item.key)}{/snippet}
</Listy>
Groups and sticky titles
group.key, title Snippet, sticky and programmatic transition to the group in normal and virtual modes.
<script lang="ts">
import { Button, Checkbox, Listy, type ListyRef } from '@woodger/antd';
const departments = ["Design", "Development", "Support"];
const items = departments.flatMap((department, group) => Array.from({ length: 12 }, (
_,
index
) => ({
id: group * 12 + index + 1,
title: `Member ${group * 12 + index + 1}`,
department
})));
let ref = $state<ListyRef>();
let virtual = $state(true);
</script>
<style>
.controls {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 12px;
margin-bottom: 16px;
}
</style>
{#snippet title(key: string, records: typeof items)}
<strong>{(key)} · {(records.length)}</strong>
{/snippet}
<div class="controls">
<Checkbox bind:checked={virtual}>{("Virtual grouping")}</Checkbox>
<Button onclick={() => ref?.scrollTo({ groupKey: "Support", align: 'top' })}>
{("To the “Support” group")}
</Button>
<Button onclick={() => ref?.scrollTo(0)}>{("To the first group")}</Button>
</div>
<Listy
items={(items)}
rowKey="id"
group={{ key: item => item.department, title }}
height={260}
sticky
{virtual}
bind:ref
aria-label={("Groups Listy")}
>
{#snippet itemRender(item)}{(item.title)}{/snippet}
</Listy>
Rows of different heights
Additional text changes line height; the virtual window respects DOM dimensions.
<script lang="ts">
import { Avatar, Button, Listy } from '@woodger/antd';
const items = [
{ id: 1, name: "Anna", text: "Updated documentation." },
{
id: 2,
name: "Boris",
text: "Invites you to discuss examples and test the behavior of components on a narrow screen."
},
{ id: 3, name: "Vera", text: "Added a comment to the task." },
{ id: 4, name: "Gleb", text: "Prepared a new version." },
{
id: 5,
name: "Daria",
text: "I checked the keyboard, field labels and returning focus after closing the window."
},
{ id: 6, name: "Egor", text: "Updated examples." }
];
let expanded = $state<ReadonlySet<number>>(new Set());
function toggle(id: number) {
const next = new Set(expanded);
if (next.has(id)) next.delete(id);
else next.add(id);
expanded = next;
}
</script>
<style>
.row {
display: flex;
align-items: flex-start;
gap: 12px;
}
.content {
flex: 1;
min-width: 0;
}
p {
margin: 8px 0;
line-height: 1.6;
}
</style>
<Listy items={(items)} rowKey="id" height={280} virtual aria-label={("Messages of different heights")}>
{#snippet itemRender(item)}
<div class="row">
<Avatar>{(item.name[0])}</Avatar>
<div class="content">
<strong>{item.name}</strong>
<p>{(item.text)}</p>
<Button size="small" aria-expanded={expanded.has(item.id)} onclick={() => toggle(item.id)}>
{(expanded.has(item.id) ? "Collapse" : "More details")}: {item.name}
</Button>
{#if expanded.has(item.id)}
<p>
{("Additional information changes the row height. Listy measures it and updates the location of neighboring entries.")}
</p>
{/if}
</div>
</div>
{/snippet}
</Listy>
Changing the order
Adaptation of drag sorting via native drag and movement buttons; React dnd-kit is not connected.
<script lang="ts">
import { Button, Listy } from '@woodger/antd';
let items = $state([
{ id: 1, title: "Documentation" }, { id: 2, title: "Examples" },
{ id: 3, title: "Versions" }, { id: 4, title: "Support" }
]);
let dragged = $state<number>();
function reorder(from: number, to: number) {
const start = items.findIndex(item => item.id === from);
const end = items.findIndex(item => item.id === to);
if (start < 0 || end < 0 || start === end) {
return;
}
const next = [...items];
const [item] = next.splice(start, 1);
next.splice(end, 0, item);
items = next;
}
function move(id: number, offset: number) {
const index = items.findIndex(item => item.id === id);
const target = items[index + offset];
if (target) reorder(id, target.id);
}
function start(event: DragEvent, id: number) {
dragged = id;
event.dataTransfer?.setData('text/plain', String(id));
}
function drop(event: DragEvent, id: number) {
event.preventDefault();
if (dragged !== undefined) reorder(dragged, id);
dragged = undefined;
}
</script>
<style>
output {
display: block;
margin-block-start: 12px;
}
.row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
}
strong { flex: 1 1 120px; }
</style>
<Listy items={(items)} rowKey="id" role="list" aria-label={("Sortable Listy")}>
{#snippet itemRender(item, index)}
<div
class="row" role="listitem" draggable="true"
ondragstart={event => start(event, item.id)}
ondragend={() => { dragged = undefined; }}
ondragover={event => event.preventDefault()}
ondrop={event => drop(event, item.id)}
>
<strong>{(item.title)}</strong>
<Button
size="small"
aria-label={("Up: " + String((item.title)) + "")}
disabled={index === 0}
onclick={() => move(item.id, -1)}
>↑</Button>
<Button size="small" aria-label={("Down: " + String((item.title)) + "")} disabled={index
=== items.length - 1}
onclick={() => move(item.id, 1)}>↓</Button>
</div>
{/snippet}
</Listy>
<output
aria-label={("Order Listy")}
>{items.map(item => item.title).join(', ')}</output>
Loading when scrolling
onScroll adds the next local portion. The button performs the same action from the keyboard.
<script lang="ts">
import { Button, Listy, type ListyRef } from '@woodger/antd';
const records = Array.from({ length: 80 }, (_, index) => ({ id: index + 1 }));
let count = $state(20);
const items = $derived(records.slice(0, count));
let ref = $state<ListyRef>();
function loadMore() {
count = Math.min(count + 20, records.length);
}
function onScroll(event: Event & { currentTarget: HTMLDivElement }) {
const node = event.currentTarget;
if (node.scrollHeight - node.clientHeight - node.scrollTop < 32) loadMore();
}
</script>
<style>
.actions {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 12px;
margin-top: 16px;
}
</style>
<Listy
items={(items)}
rowKey="id"
height={240}
virtual
{onScroll}
bind:ref
aria-label={("Portions Listy")}
>
{#snippet itemRender(item)}{("Material ")}{(item.id)}{/snippet}
</Listy>
<div class="actions">
<Button
disabled={count === records.length}
onclick={loadMore}
>{("Load more")}</Button>
<Button onclick={() => ref?.scrollTo({ key: count, align: 'bottom' })}>
{("At the end of the portion")}
</Button>
<output aria-label={("Portion Listy")}>{("Uploaded: ")}{count}{(" from ")}{(records.length)}</output>
</div>
Semantic DOM and ConfigProvider
Semantic styles object and function, common ConfigProvider.listy and slots highlighting.
<script lang="ts">
import { Checkbox, ConfigProvider, Listy } from '@woodger/antd';
const items = [
{ id: 1, department: "Design", title: "Anna" },
{ id: 2, department: "Design", title: "Boris" },
{ id: 3, department: "Development", title: "Vera" }
];
let highlight = $state(false);
</script>
<style>
.examples {
display: grid;
gap: 24px;
margin-top: 20px;
}
.examples :global(.listy-slot) {
outline: 1px dashed var(--ant-color-primary);
outline-offset: -1px;
}
</style>
{#snippet title(key: string, records: typeof items)}{(key)} · {(records.length)}{/snippet}
<Checkbox bind:checked={highlight}>{("Highlight slots Listy")}</Checkbox>
<ConfigProvider listy={{ styles: { item: 'padding-block:10px' } }}>
<div class="examples">
<Listy
items={(items)} rowKey="id" group={{ key: item => item.department, title }}
classNames={highlight
? { root: 'listy-slot', item: 'listy-slot', groupHeader: 'listy-slot' }
: {}}
styles={{
root: `
border: 1px solid var(--ant-color-border);
border-radius: 8px;
overflow: hidden;
`,
groupHeader: 'color:var(--ant-color-primary-text)',
item: 'padding-inline:20px'
}}
>
{#snippet itemRender(item)}{(item.title)}{/snippet}
</Listy>
<Listy
items={(items)}
rowKey="id"
sticky
group={{ key: item => item.department, title }}
classNames={() => highlight ? { root: 'listy-slot', groupHeader: 'listy-slot' } : {}}
styles={({ props }) => ({
groupHeader: props.sticky
? 'font-weight:700'
: 'font-weight:400',
item: 'padding-inline:24px'
})}
>
{#snippet itemRender(item)}{(item.title)}{/snippet}
</Listy>
</div>
</ConfigProvider>
Search and empty state
Filtering belongs to the application; Empty is shown explicitly if there are no matches.
<script lang="ts">
import { Button, Empty, Input, Listy } from '@woodger/antd';
const records = [
{ id: 1, name: "Anna" }, { id: 2, name: "Boris" }, { id: 3, name: "Vera" }
];
let query = $state<string | undefined>('');
const items = $derived(records.filter(item =>
item.name.toLowerCase().includes((query ?? '').trim().toLowerCase())
));
</script>
<style>
output {
display: block;
margin-block-start: 12px;
}
.controls {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 12px;
margin-bottom: 20px;
}
.field { width: 200px; }
</style>
<div class="controls">
<div class="field"><Input aria-label={("Search Listy")} bind:value={query} /></div>
<Button onclick={() => { query = ''; }}>{("Reset search")}</Button>
</div>
{#if items.length}
<Listy items={(items)} rowKey="id" aria-label={("Search Results Listy")}>
{#snippet itemRender(item)}{item.name}{/snippet}
</Listy>
{:else}
<Empty image="simple" description={("No matches")} />
{/if}
<output aria-label={("Search Result Listy")}>{("Found: ")}{(items.length)}</output>
List from review
Saved example: 200 records, grouping, going to the last record and returning to the beginning.
<script lang="ts">
import { Button, Listy, type ListyRef } from '@woodger/antd';
const items = Array.from({ length: 200 }, (_, index) => ({
id: index + 1,
title: `Record ${String(index + 1).padStart(3, '0')}`,
group: `Group ${Math.floor(index / 50) + 1}`
}));
let ref = $state<ListyRef>();
let grouped = $state(true);
</script>
<style>
.controls {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 12px;
margin-bottom: 16px;
}
.controls label {
display: flex;
align-items: center;
gap: 8px;
}
.list {
max-width: 640px;
border: 1px solid var(--ant-color-border-secondary);
border-radius: 8px;
overflow: hidden;
}
.row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
min-height: 44px;
}
.row span {
color: var(--ant-color-text-secondary);
font-size: 12px;
}
</style>
{#snippet title(key: string, entries: typeof items)}<strong>{(key)} · {(entries.length)}{(" records")}</strong>{/snippet}
<div class="controls">
<label><input type="checkbox" bind:checked={grouped} />{(" Groups with fixed headings")}</label>
<Button onclick={() => ref?.scrollTo({ key: 200, align: 'bottom' })}>
{("To entry 200")}
</Button>
<Button onclick={() => ref?.scrollTo({ top: 0 })}>{("To the top of the list")}</Button>
</div>
<div class="list">
<Listy
items={(items)}
rowKey="id"
height={260}
virtual
sticky
group={grouped ? { key: item => item.group, title } : undefined}
bind:ref
aria-label={("Virtual list of records")}
>
{#snippet itemRender(item)}
<div
class="row"
><strong>{(item.title)}</strong><span>№ {(item.id)}</span></div>
{/snippet}
</Listy>
</div>
Listy is an independent component of the package. The prefix applies in raw and virtual modes, to groups and scrollbars. When changing the prefix, lines and scrolling are preserved; mode switching is shown separately.
CSS prefixes Listy
Common namespace ConfigProvider and local prefixCls; the state of the component is preserved when the name is changed.
<script lang="ts">
import { Checkbox, ConfigProvider, Listy, Input } from '@woodger/antd';
let custom = $state(true);
let local = $state(true);
const prefix = $derived(custom ? 'suite' : 'ant');
const localPrefix = $derived(local ? 'project-listy' : '');
let virtual = $state(false);
const items = Array.from({ length: 40 }, (_, index) => ({
id: index,
title: `String ${index + 1}`
}));
</script>
<style>
.example,
.prefix-stage {
display: grid;
grid-template-columns: minmax(0, 1fr);
gap: 16px;
min-width: 0;
}
.controls {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
p { margin: 0; }
output { overflow-wrap: anywhere; }
</style>
<div class="example">
<div class="controls">
<Checkbox bind:checked={custom}>{("Common prefix Listy suite")}</Checkbox>
<Checkbox bind:checked={local}>{("Local prefix Listy")}</Checkbox>
</div>
<ConfigProvider prefixCls={prefix} theme={{ cssVar: { prefix: 'listy-theme' } }}>
<div class="prefix-stage">
<Checkbox bind:checked={virtual}>{("Virtual Listy with prefix")}</Checkbox>
<Listy prefixCls={localPrefix} items={(items)} rowKey="id" {virtual} height={200}
aria-label={("Listy with prefix")} role="list">
{#snippet itemRender(item)}
<div role="listitem" style="padding:8px">
<Input defaultValue={item.title} aria-label={("Draft " + String((item.title)) + " with prefix")} />
</div>
{/snippet}
</Listy>
</div>
</ConfigProvider>
<output
aria-label={("CSS prefix Listy")}
>{("General: ")}{prefix}{("; local: ")}{(localPrefix
|| ("from the provider"))}</output>
<p>
{("Listy is an independent component of the package. The prefix applies in raw and virtual modes, to groups and scrollbars. When changing the prefix, lines and scrolling are preserved; mode switching is shown separately.")}
</p>
</div>
API
Verified against eight ant.design 6.7.0 themes and public Svelte API based on 6.6.8.
scrollWidth and rowHoverable, introduced in 6.7.0, has not yet been transferred. Full definitions of Props are in the package.
| Theme | Example or limitation |
|---|---|
| Basic | Keys and own markings. |
| Virtual scrolling | Window of thousands of records. |
| Horizontal scrolling | scrollWidth was added in ant.design 6.7.0 and is missing from the current Svelte API based on 6.6.8. |
| Grouping and sticky headers | Raw/virtual and scrollTo groups. |
| Rich content | Measuring lines of varying height. |
| Drag sorting | Native drag and buttons. Integration with React dnd-kit was not ported. |
| Infinite loading | onScroll, local portions and virtual. |
| Custom semantic dom styling | Object, function and context settings. |
| Property | Description | Type | Default |
|---|---|---|---|
prefixCls | Full CSS prefix of the component and its parts. A non-empty local prop takes precedence; empty string and undefined inherit ConfigProvider. The namespace of the topic is set separately. | string | ConfigProvider.prefixCls + "-listy" |
items | Original records. | readonly T[] | [] |
rowKey | Stable key; There is no automatic fallback to the index. | keyof T | (item) => ListyKey | is required |
itemRender | Contents of the string. The index refers to the original items. | Snippet<[T, number]> | is required |
height | Scrollable area height; a positive value is needed for a virtual window. | number | — |
virtual | Mounts only part of the lines at a given height. | boolean | context / false |
group | key calculates the group, title - Snippet of the title. | ListyGroup<T, K> | — |
sticky | Freezes the title of the current group. | boolean | false |
onScroll | currentTarget - root in raw mode or internal holder in virtual mode. onscroll is a compatible alias. | native UIEvent handler | — |
styles | CSS lines root/item/groupHeader; object or function with raw props. | ListySemantic | — |
classNames | Classes root/item/groupHeader; object or function. | ListySemantic | — |
nativeElement | bind:nativeElement - root div; in virtual mode it wraps the holder. | HTMLDivElement | after mount |
ref | bind:ref provides scrollTo; binding is cleared upon unmount. | ListyRef | after mount |
Group
key calculates the string, numeric, or bigint key of a group. Records with the same key are merged across all items in the order of the first occurrence of the group. title —
Snippet<[groupKey, items]>. The itemRender index remains the index of the original entry.
ref.scrollTo
| Argument | Action |
|---|---|
number | Vertical offset in pixels. |
{ top?, left? } | Absolute position; horizontal virtual window is not implemented in the current package. |
{ key, align?, offset? } | Record by rowKey; align: top, bottom or auto. |
{ groupKey, align?, offset? } | Group header in virtual mode, group section in raw mode. |
Semantic DOM
Listy uses div containers; itemRender markup belongs to the application. A simple example shows list/listitem and entry numbers. Links, fields and buttons within a row retain native semantics and Tab order.
| Slot | Purpose |
|---|---|
root | Root container of the list. |
item | Record container: padding, separator and hover. |
groupHeader | Group title, including pinned copy. |
ConfigProvider.listy specifies the general class/style and semantic styles. Local meanings complement and clarify the context. The function receives the initial props, before applying defaults. Turn on the highlight in the example to see the boundaries of the slots.
Registration tokens
The itemPaddingBlock and itemPaddingInline component tokens are applied via
theme.components.Listy. Semantic styles allow you to specify local indentations. An arbitrary prefixCls changes the classes but does not generate the corresponding CSS.
| Token | Purpose |
|---|---|
itemPaddingBlock | Vertical record indents. |
itemPaddingInline | Horizontal record indents. |
| Token | Meaning |
|---|---|
colorText | rgba(0,0,0,0.88) |
colorTextDescription | rgba(0,0,0,0.45) |
colorBgContainer | #ffffff |
colorSplit | rgba(5,5,5,0.06) |
controlItemBgHover | rgba(0,0,0,0.04) |
fontSize | 14 |
lineHeight | 1.5714285714285714 |
fontWeightStrong | 600 |
FAQ
Why does virtual output all lines?
Check the positive height and length of the content. Without height or zero, the virtual window does not limit the list.
Where is loading, pagination and Empty?
They are added by an application around Listy. Empty items by itself does not create an Empty.
How do lines of different heights work?
After mount the list measures the DOM. Preserve rowKey when content changes.
Has drag sorting been completely transferred?
No. The example is adapted using native drag and buttons; external React sensors are not included in it.