General
Empty
Usage#
import { WdsEmptyComponent } from '@wds/angular/empty';Examples#
Default#
import { Component } from '@angular/core';
import { WdsEmptyComponent } from '@wds/angular/empty';
import { WdsButtonComponent } from '@wds/angular/button';
import '@wds/core/icons/lucide/folder-closed';
@Component({
selector: 'app-empty-default-demo',
imports: [WdsEmptyComponent, WdsButtonComponent],
template: `
<wds-empty media="icon" heading="No Projects Yet" description="You haven't created any projects yet. Get started by creating your first project." icon="lucide-folder-closed">
<div class="flex flex-wrap justify-center gap-2">
<wds-button>Create Project</wds-button>
<wds-button variant="outline">Import Project</wds-button>
</div>
<wds-button variant="link" size="sm" href="#">Learn More →</wds-button>
</wds-empty>
`,
})
export class EmptyDefaultDemo {}Outline#
outline adds a dashed border.
import { Component } from '@angular/core';
import { WdsEmptyComponent } from '@wds/angular/empty';
import { WdsButtonComponent } from '@wds/angular/button';
import '@wds/core/icons/lucide/cloud-upload';
@Component({
selector: 'app-empty-outline-demo',
imports: [WdsEmptyComponent, WdsButtonComponent],
template: `
<wds-empty outline media="icon" heading="Cloud Storage Empty" description="Upload files to your cloud storage to access them anywhere." icon="lucide-cloud-upload">
<wds-button variant="outline" size="sm">Upload Files</wds-button>
</wds-empty>
`,
})
export class EmptyOutlineDemo {}Background#
import { Component } from '@angular/core';
import { WdsEmptyComponent } from '@wds/angular/empty';
import { WdsButtonComponent } from '@wds/angular/button';
import '@wds/core/icons/lucide/bell';
@Component({
selector: 'app-empty-background-demo',
imports: [WdsEmptyComponent, WdsButtonComponent],
template: `
<wds-empty
class="w-full rounded-lg bg-[linear-gradient(to_top,var(--wds-muted),transparent_70%)]"
media="icon"
heading="No Notifications"
description="You're all caught up. New notifications will appear here."
icon="lucide-bell"
>
<wds-button variant="outline" size="sm">Refresh</wds-button>
</wds-empty>
`,
})
export class EmptyBackgroundDemo {}Avatar#
media="icon" the media slot shows an image or an avatar as is.
import { Component } from '@angular/core';
import { WdsEmptyComponent } from '@wds/angular/empty';
import { WdsAvatarComponent } from '@wds/angular/avatar';
import { WdsButtonComponent } from '@wds/angular/button';
@Component({
selector: 'app-empty-avatar-demo',
imports: [WdsEmptyComponent, WdsAvatarComponent, WdsButtonComponent],
template: `
<wds-empty heading="User Offline" description="This user is currently offline. You can leave a message to notify them or try again later.">
<wds-avatar slot="media" class="grayscale [--wds-avatar-size:48px]" src="https://github.com/octocat.png" aria-hidden="true">OC</wds-avatar>
<wds-button size="sm">Leave Message</wds-button>
</wds-empty>
`,
})
export class EmptyAvatarDemo {}Input group#
import { Component } from '@angular/core';
import { WdsEmptyComponent } from '@wds/angular/empty';
import { WdsInputGroupAddonComponent, WdsInputGroupComponent } from '@wds/angular/input-group';
import { WdsInputComponent } from '@wds/angular/input';
import { WdsKbdComponent } from '@wds/angular/kbd';
import '@wds/core/icons/lucide/search';
@Component({
selector: 'app-empty-input-group-demo',
imports: [WdsEmptyComponent, WdsInputGroupComponent, WdsInputGroupAddonComponent, WdsInputComponent, WdsKbdComponent],
template: `
<wds-empty heading="404 - Not Found" description="The page you're looking for doesn't exist. Try searching for what you need below.">
<wds-input-group class="w-full">
<wds-input placeholder="Try searching for pages..." aria-label="Search pages"></wds-input>
<wds-input-group-addon icon="lucide-search"></wds-input-group-addon>
<wds-input-group-addon align="inline-end"><wds-kbd>/</wds-kbd></wds-input-group-addon>
</wds-input-group>
<span class="text-(length:--wds-font-size-sm) text-muted-foreground">Need help? <a class="text-inherit underline-offset-4" href="#">Contact support</a></span>
</wds-empty>
`,
})
export class EmptyInputGroupDemo {}Slots#
title and description slots replace the attributes when the text needs markup or links.
import { Component } from '@angular/core';
import { WdsEmptyComponent } from '@wds/angular/empty';
import '@wds/core/icons/lucide/search';
@Component({
selector: 'app-empty-slots-demo',
imports: [WdsEmptyComponent],
template: `
<wds-empty outline media="icon" icon="lucide-search">
<span slot="title">No results for “<strong>lit radio</strong>”</span>
<span slot="description">Check the spelling or <a class="text-inherit underline-offset-4 hover:text-primary" href="#">clear the filters</a>.</span>
</wds-empty>
`,
})
export class EmptySlotsDemo {}API References#
wds-empty#
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
| heading | string | '' | title slot takes precedence. |
| description | string | '' | description slot takes precedence. |
| heading-level.headingLevel | number | 3 | aria-level). |
| media | WdsEmptyMedia | 'default' | icon shows the icon on a muted 40×40 background. |
| icon | string | undefined | media="icon" on a muted background). The name of a registered icon, e.g. lucide-inbox (after import '@wds/core/icons/lucide/inbox'). | |
| outline | boolean | false |
Slots
| Slot | Description |
|---|---|
| (default) | |
| media | icon. |
| title | heading). |
| description | description), may contain links. |
CSS parts (::part)
| Part | Description |
|---|---|
| empty | |
| header | |
| media | media="icon" the background behind the icon). |
| title | |
| description | |
| content |
CSS custom properties
| Property | Description |
|---|---|
| --wds-empty-padding | |
| --wds-empty-radius |
Accessibility#
Screen reader#
role="heading" with aria-level from heading-level (default 3). Set the level that fits the outline of the page.
aria-hidden="true" and images alt="", or a real alt when the image carries information.