Empty
Empty states, illustrations, creating the first record and general renderEmpty.
When to use
Empty explains a completed state with no entries: a new project, an empty list, or no search results. The message should prompt the next step - create a record, change the query, or reset the filter.
While the request is running, use Spin or Skeleton. Loading failure requires a reason and retry message; it does not mean the absence of data.
Illustration, description and action
Image selects an embedded illustration, URL or snippet. description specifies an explanation; without an explicit value, the current locale is used. children contains additional content, usually an action button.
| Problem | Opportunity | Example |
|---|---|---|
| Show missing data | defaults | Basic option |
| Fit a fortune into a small area | image="simple" |
Compact picture |
| Add your image and button | image, description, children |
Net worth |
| Remove signature | description={false} |
No text |
| Replace generic empty lists | ConfigProvider.renderEmpty | General composition |
Built-in options are selected with the default/simple lines. The other string image is treated as a URL. Set the size of the illustration using styles.image, and not the style of the entire Empty. For a complex description, use a snippet with short text and relevant links.
Locale and general settings
ConfigProvider.locale.empty changes the default signature. Explicit description takes precedence; false hides the description completely. ConfigProvider.empty specifies the inherited illustration, class/style and semantic defaults.
RenderEmpty is a separate snippet of a common provider for empty content of supported components: Select, TreeSelect, Cascader, Transfer and Table. It does not replace the description of each randomly placed Empty. general example shows exactly the consuming components of this context.
Nested providers allow you to independently change the language and design of different areas. The Empty settings and the general renderEmpty function solve different problems: the first design the component, the second creates the contents of the empty result.
Availability and transition to data
The illustration is decorative and should not provide a single explanation. Communicate the meaning with a description, and the action with a native button or link with a clear name.
After the first entry is created, Empty disappears along with its button. Set the focus to the data area to be saved or the new record in advance. In applied example this is a table area; After clearing the list, focus returns to the input field.
classNames/styles support root, image, description and footer, an object or a callback from props. Svelte styles contains CSS strings. bind:nativeElement returns the root div after the mount. Empty does not have a separate set of component design tokens; it uses a common theme and semantic styles.
prefixCls specifies the full local CSS prefix Empty. The empty string and undefined inherit ConfigProvider.prefixCls with the -empty suffix, defaulting to ant-empty. Changing classes preserves the drawing, description and semantic styles; namespace CSS variables do not change. Example ConfigProvider shows common inheritance.
Examples
Empty state
Inline artwork and caption from the current locale.
<script lang="ts">
import { Empty } from '@woodger/antd';
</script>
<Empty aria-label={("Empty default state")} />
Compact illustration
image="simple" is suitable for empty lists and small areas.
<script lang="ts">
import { Empty } from '@woodger/antd';
</script>
<Empty image="simple" description={("No tasks yet")} />
The document has not been created yet.
Picture, description and action
Illustration URL, size via styles.image, Snippet description and create button.
<script lang="ts">
import { Button, Empty } from '@woodger/antd';
const image = 'data:image/svg+xml,' + encodeURIComponent(
'<svg xmlns="http://www.w3.org/2000/svg" width="160" height="100" viewBox="0 0 160 100"><rect x="20" y="12" width="120" height="76" rx="12" fill="#f6ffed" stroke="#b7eb8f"/><path d="M56 50h48m-24-24v48" stroke="#389e0d" stroke-width="4"/></svg>'
);
let created = $state(false);
</script>
{#snippet description()}
<strong>{("There are no documents in this folder yet")}</strong>
<div>{("Create your first document to get started.")}</div>
{/snippet}
<Empty {image} description={(description)} styles={{ image: 'height:80px' }}>
<Button type="primary" disabled={created} onclick={() => { created = true; }}>
{("\n Create document\n ")}
</Button>
</Empty>
<p role="status" aria-label={("Creating a document")}>
{(created ? "The document has been created." : "The document has not been created yet.")}
</p>
Select
TreeSelect
Cascader
Transfer
Name |
|---|
Data not found |
General empty state
ConfigProvider.renderEmpty sets the contents of Select, TreeSelect, Cascader, Transfer and Table.
<script lang="ts">
import {
Cascader, Checkbox, ConfigProvider, Empty, Select, Table, Transfer, TreeSelect
} from '@woodger/antd';
let custom = $state(true);
</script>
<style>
.examples {
display: grid;
gap: 24px;
margin-top: 24px;
min-width: 0;
}
.field { max-width: 300px; }
h4 {
margin: 0 0 8px;
font-size: 14px;
font-weight: 600;
}
.transfer {
max-width: 100%;
overflow-x: auto;
}
</style>
{#snippet empty()}
<Empty image="simple" description={("Data not found")} />
{/snippet}
<Checkbox bind:checked={custom}>{("General empty state")}</Checkbox>
<ConfigProvider
renderEmpty={custom ? () => empty : undefined}
empty={{ styles: { description: 'color:var(--ant-color-text-secondary)' } }}
>
<div class="examples">
<div class="field">
<h4>Select</h4>
<Select
options={([])}
aria-label={("Empty Select")}
placeholder={("Select entry")}
/>
</div>
<div class="field">
<h4>TreeSelect</h4>
<TreeSelect
treeData={[]}
aria-label={("Empty TreeSelect")}
placeholder={("Select node")}
/>
</div>
<div class="field">
<h4>Cascader</h4>
<Cascader
options={([])}
aria-label={("Empty Cascader")}
placeholder={("Select path")}
/>
</div>
<div class="transfer">
<h4>Transfer</h4>
<Transfer
dataSource={([])}
titles={(["Available", "Selected"])}
/>
</div>
<Table
dataSource={([])}
columns={([{ key: 'name', title: "Name", dataIndex: 'name' }])}
pagination={(false)}
caption={("General empty table state")}
/>
</div>
</ConfigProvider>
Semantic DOM
The styles/classNames object and function style root, image, description and footer.
<script lang="ts">
import { Button, Checkbox, Empty } from '@woodger/antd';
let highlight = $state(false);
let actions = $state(0);
</script>
<style>
.examples {
display: grid;
gap: 24px;
margin-top: 24px;
}
.examples :global(.empty-slot) { outline: 1px dashed var(--ant-color-primary); }
output {
display: block;
margin-top: 16px;
}
</style>
<Checkbox bind:checked={highlight}>{("Highlight semantic slots")}</Checkbox>
<div class="examples">
<Empty
description={("Styles by object")}
classNames={highlight ? {
root: 'empty-slot', image: 'empty-slot', description: 'empty-slot', footer: 'empty-slot'
} : undefined}
styles={{
root: `
padding: 16px;
border-radius: 8px;
background: var(--ant-color-fill-quaternary);
`,
image: 'height:64px',
description: 'font-weight:600',
footer: 'margin-top:20px'
}}
>
<Button onclick={() => { actions++; }}>{("Create entry")}</Button>
</Empty>
<Empty
image="simple"
description={("Styles function")}
classNames={() => highlight ? { root: 'empty-slot', description: 'empty-slot' } : {}}
styles={({ props }) => ({
root: 'padding:16px',
description: props.image === 'simple' ? 'font-weight:600' : undefined
})}
/>
</div>
<output
aria-label={("Actions semantic Empty")}
>{("Created records: ")}{actions}</output>
No description
description={false} leaves the illustration without a caption.
<script lang="ts">
import { Empty } from '@woodger/antd';
</script>
<Empty
description={(false)}
aria-label={("Empty state without label")}
/>
Russian
English
Locale and Empty settings
Local ConfigProvider changes the language and inherited illustration independently of each other.
<script lang="ts">
import { ConfigProvider, Empty, enUS, ruRU } from '@woodger/antd';
</script>
<style>
.examples {
display: grid;
gap: 24px;
}
h4 {
margin: 0;
font-size: 14px;
font-weight: 600;
}
</style>
<div class="examples">
<div lang="ru">
<h4>{("Russian")}</h4>
<ConfigProvider locale={ruRU} empty={{ image: 'simple' }}>
<Empty aria-label={("Russian locale")} />
</ConfigProvider>
</div>
<div lang="en">
<h4>English</h4>
<ConfigProvider locale={enUS} empty={{ image: 'simple' }}>
<Empty aria-label={("English locale")} />
</ConfigProvider>
</div>
</div>
Name | Role |
|---|---|
There are no participants yet. | |
Participants and search
Add the first team member or see what the team sees when a search returns no results.
<script lang="ts">
import { Button, Checkbox, Empty, Input, Select, Table, type TableColumn } from '@woodger/antd';
interface Member {
key: number;
name: string;
role: string;
}
let image = $state<'default' | 'simple' | 'custom' | 'none'>('default');
let description = $state<'text' | 'rich' | 'none'>('text');
let text = $state<string | undefined>(("There is nothing here yet."));
let actions = $state(true);
let actionCount = $state(0);
let members = $state<Member[]>([]);
let name = $state<string | undefined>(("Anna"));
let query = $state<string | undefined>('');
let tableHost = $state<HTMLDivElement>();
let nextKey = 0;
let visible = $derived(
members.filter(
member =>
member.name.toLowerCase().includes((query ?? '').trim().toLowerCase())
)
);
const columns: TableColumn<Member>[] = [
{ key: 'name', title: "Name", dataIndex: 'name' },
{ key: 'role', title: "Role", dataIndex: 'role' }
];
function focusTable() {
const table = tableHost?.querySelector<HTMLElement>('.ant-table-content');
table?.focus({ preventScroll: true });
}
function addMember() {
const value = name?.trim();
if (!value) {
return;
}
focusTable();
query = '';
members = [...members, { key: nextKey++, name: value, role: "Member" }];
}
function resetSearch() {
focusTable();
query = '';
}
function clearMembers() {
const input = document.getElementById('empty-example-name');
input?.focus({ preventScroll: true });
members = [];
query = '';
}
</script>
<style>
.controls {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 12px;
}
.fields { align-items: flex-end; }
.fields :global(.ant-btn) {
max-width: 100%;
height: auto;
min-height: var(--ant-control-height);
white-space: normal;
}
.fields :global(.ant-btn-sm) { min-height: var(--ant-control-height-sm); }
.fields :global(.ant-btn-lg) { min-height: var(--ant-control-height-lg); }
.field { width: 180px; }
.wide {
width: 260px;
max-width: 100%;
}
.wide label {
display: block;
margin-bottom: 8px;
}
.preview {
margin-block: 24px;
padding: 20px;
border: 1px solid var(--ant-color-border-secondary);
border-radius: var(--ant-border-radius-lg);
}
.table { margin-top: 20px; }
output {
display: block;
margin-top: 20px;
color: var(--ant-color-text-secondary);
}
</style>
{#snippet customImage()}<svg width="160" height="100" viewBox="0 0 160 100" aria-hidden="true"><rect
x="24"
y="20"
width="112"
height="64"
rx="12"
fill="var(--ant-color-primary-bg)"
stroke="var(--ant-color-primary-border)"
/><path
d="M56 52h48m-24-24v48"
fill="none"
stroke="var(--ant-color-primary)"
stroke-width="4"
/></svg>{/snippet}
{#snippet richDescription()}<strong>
{(text || ("No entries"))}
</strong><br /><span>
{("Add your first entry to get started.")}
</span>{/snippet}
{#snippet previewActions()}
<Button type="primary" onclick={() => { actionCount++; }}>
{("Try the Empty action")}
</Button>
{/snippet}
{#snippet emptyMembers()}<Empty
image="simple"
description={(members.length ? "Nothing was found for your request." : "There are no participants yet.")}
>{#if members.length}<Button
onclick={resetSearch}
>{("Reset search for participants")}</Button>{:else}<Button
type="primary"
disabled={!name?.trim()}
onclick={addMember}
>{("Create first participant")}</Button>{/if}</Empty>{/snippet}
<div class="controls"><div class="field"><Select
aria-label={("Illustration Empty")}
bind:value={image}
options={([
{ value: 'default', label: 'default' },
{ value: 'simple', label: 'simple' },
{ value: 'custom', label: "Own Snippet" },
{ value: 'none', label: "No picture" }
])}
/></div><div class="field"><Select
aria-label={("Description Empty")}
bind:value={description}
options={([
{ value: 'text', label: "Text" },
{ value: 'rich', label: 'Snippet' },
{ value: 'none', label: "No description" }
])}
/></div><div
class="wide"
><Input
aria-label={("Text Empty")}
bind:value={text}
/></div><Checkbox
bind:checked={actions}
>{("Action Empty")}</Checkbox></div>
<div class="preview"><Empty
image={image === 'custom' ? customImage : image === 'none' ? false : image}
description={description === 'rich' ? richDescription : description === 'none' ? false : (text
?? '')}
children={actions ? previewActions : undefined}
aria-label={("Customizable empty state")}
/></div>
<div class="controls fields"><div class="wide"><label for="empty-example-name">
{("New member name")}
</label><Input
id="empty-example-name"
bind:value={name}
/></div><Button
disabled={!name?.trim()}
onclick={addMember}
>{("Add participant to Empty example")}</Button><Button
disabled={!members.length}
onclick={clearMembers}
>{("Clear list of participants")}</Button><div
class="wide"
><label
for="empty-example-search"
>{("Search in Empty example")}</label><Input
id="empty-example-search"
aria-label={("Search in Empty example")}
bind:value={query}
/></div></div>
<div class="table" bind:this={tableHost}><Table
dataSource={(visible)}
columns={(columns)}
pagination={(false)}
caption={("Participants of the Empty example")}
empty={emptyMembers}
/></div>
<output
aria-label={("Example result Empty")}
>{("Participants: ")}{(members.length)}{(". Shown: ")}{(visible.length)}{(". Actions: ")}{actionCount}.</output>
API
Verified against six ant.design 6.6.8 page themes and @woodger/antd public types. Full Props definitions belong to the package.
| Theme | Example |
|---|---|
| Basic | Standard empty state. |
| Choose image | Built-in compact illustration. |
| Customize | URL, size, Snippet and action. |
| ConfigProvider | Total contents of five components. |
| Custom semantic dom styling | Styles object and function. |
| No description | Explicitly disable label. |
| Property | Description | Type | Default |
|---|---|---|---|
prefixCls | Full local CSS prefix for the root, image, and description of the Empty. The empty string and undefined inherit ConfigProvider.prefixCls; the default is ant-empty. | string | ConfigProvider + -empty |
image | default, simple, URL or Snippet; false hides the illustration. | EmptyImage | default / context |
description | Text, number or Snippet; false hides the label. | EmptyDescription | from locale |
children | Additional content, such as a create button. | EmptyContent | — |
styles | CSS lines by semantic slots; object or function ({ props }). | EmptySemantic | — |
classNames | Classes by semantic slots; object or function ({ props }). | EmptySemantic | — |
nativeElement | bind:nativeElement gives access to the root DOM element. | HTMLDivElement | after mount |
ref | bind:ref provides nativeElement; cleared when unmounted. | EmptyRef | after mount |
Built-in images
Instead of React constants Empty.PRESENTED_IMAGE_DEFAULT and
Empty.PRESENTED_IMAGE_SIMPLE pass image="default" or
image="simple". The remaining lines are considered URLs. Snippet allows you to insert your own illustration, false hides it.
ConfigProvider
empty specifies the image and decoration of the Empty instances inside the provider.
renderEmpty(componentName) returns the contents of the empty area of other components. A parameter of the component itself, for example Table.empty or
Select.notFoundContent, takes precedence over the general handler.
Semantic DOM
Turn on highlighting in the Semantic DOM example to see the borders of elements.
styles accepts CSS strings, classNames - class names; both options support object and function with props.
| Slot | Purpose |
|---|---|
root | Root: alignment and typography. |
image | Decorative illustration and its dimensions. |
description | Empty state label. |
footer | Additional actions under the label. |
The illustration is decorative and hidden from the accessibility tree. Convey the meaning of the state in the description text. For a dynamic action result, use a separate
role="status"; Empty itself does not automatically announce changes.
Registration tokens
Empty does not have its own component tokens. Dimensions, padding, and label use common theme tokens. Semantic styles are suitable for designing one instance.
| Token | Meaning |
|---|---|
colorTextDescription | rgba(0,0,0,0.45) |
controlHeightLG | 40 |
fontSize | 14 |
lineHeight | 1.5714285714285714 |
margin | 16 |
marginXL | 32 |
marginXS | 8 |
opacityImage | 1 |
FAQ
How is the empty state different from an error?
Empty means that the result was received, but there were no records. Loading and error require their own messages and actions.
How to change the language?
Pass locale to ConfigProvider. An explicit description will replace the localized caption; false will hide it.
Why did I lose focus after creating a post?
The Empty button is deleted along with its state. Bring focus to the area to be saved or to a new object before deleting.