Run the CLI
Use the CLI to add the component to your project.
npx @ngzard/ui@latest add emptyThe Empty component displays a placeholder when no data is available, commonly used in tables, lists, or search results.
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { ZardButtonComponent } from '../../button/button.component';
import { ZardIconComponent } from '../../icon/icon.component';
import { ZardEmptyComponent } from '../empty.component';
@Component({
selector: 'z-demo-empty-default',
imports: [ZardButtonComponent, ZardEmptyComponent, ZardIconComponent],
template: `
<z-empty
zIcon="folder-code"
zTitle="No Projects Yet"
zDescription="You haven't created any projects yet. Get started by creating your first project."
[zActions]="[actionPrimary, actionSecondary]"
>
<ng-template #actionPrimary>
<button type="button" z-button>Create Project</button>
</ng-template>
<ng-template #actionSecondary>
<button type="button" z-button zType="outline">Import Project</button>
</ng-template>
<button type="button" z-button zType="link" zSize="sm" class="text-muted-foreground">
Learn More
<z-icon zType="arrow-up-right" />
</button>
</z-empty>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ZardDemoEmptyDefaultComponent {}
Use the CLI to add the component to your project.
npx @ngzard/ui@latest add emptypnpm dlx @ngzard/ui@latest add emptyyarn dlx @ngzard/ui@latest add emptybunx @ngzard/ui@latest add emptyCreate the component directory structure and add the following files to your project.
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { ZardButtonComponent } from '../../button/button.component';
import { ZardIconComponent } from '../../icon/icon.component';
import { ZardEmptyComponent } from '../empty.component';
@Component({
selector: 'z-demo-empty-default',
imports: [ZardButtonComponent, ZardEmptyComponent, ZardIconComponent],
template: `
<z-empty
zIcon="folder-code"
zTitle="No Projects Yet"
zDescription="You haven't created any projects yet. Get started by creating your first project."
[zActions]="[actionPrimary, actionSecondary]"
>
<ng-template #actionPrimary>
<button type="button" z-button>Create Project</button>
</ng-template>
<ng-template #actionSecondary>
<button type="button" z-button zType="outline">Import Project</button>
</ng-template>
<button type="button" z-button zType="link" zSize="sm" class="text-muted-foreground">
Learn More
<z-icon zType="arrow-up-right" />
</button>
</z-empty>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ZardDemoEmptyDefaultComponent {}
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { ZardButtonComponent } from '../../button/button.component';
import { ZardEmptyComponent } from '../empty.component';
@Component({
selector: 'z-demo-empty-custom-image',
imports: [ZardButtonComponent, ZardEmptyComponent],
template: `
<z-empty
zImage="images/avatar/imgs/avatar_image.jpg"
zTitle="User Offline"
zDescription="This user is currently offline. You can leave a message to notify them or try again later."
[zActions]="[actionPrimary]"
class="[&_img]:size-12 [&_img]:rounded-full [&_img]:grayscale"
/>
<ng-template #actionPrimary>
<button type="button" z-button>Leave Message</button>
</ng-template>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ZardDemoEmptyCustomImageComponent {}




import { ChangeDetectionStrategy, Component } from '@angular/core';
import { ZardAvatarGroupComponent } from '../../avatar/avatar-group.component';
import { ZardAvatarComponent } from '../../avatar/avatar.component';
import { ZardButtonComponent } from '../../button/button.component';
import { ZardIconComponent } from '../../icon/icon.component';
import { ZardEmptyComponent } from '../empty.component';
@Component({
selector: 'z-demo-empty-advanced-customization',
imports: [ZardAvatarComponent, ZardAvatarGroupComponent, ZardButtonComponent, ZardIconComponent, ZardEmptyComponent],
template: `
<z-empty
[zImage]="customImage"
[zTitle]="customTitle"
zDescription="Invite your team to collaborate on this project."
[zActions]="[actionInvite]"
/>
<ng-template #customImage>
<z-avatar-group>
<z-avatar zSrc="https://github.com/srizzon.png" zSize="md" class="grayscale" />
<z-avatar zSrc="https://github.com/Luizgomess.png" zSize="md" class="grayscale" />
<z-avatar zSrc="https://github.com/ribeiromatheuss.png" zSize="md" class="grayscale" />
<z-avatar zSrc="https://github.com/mikij.png" zSize="md" class="grayscale" />
</z-avatar-group>
</ng-template>
<ng-template #customTitle>
<span>
No Team
<strong>members</strong>
</span>
</ng-template>
<ng-template #actionInvite>
<button type="button" z-button zSize="sm">
<i z-icon zType="plus"></i>
Invite Members
</button>
</ng-template>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ZardDemoEmptyAdvancedComponent {}