Presets

Blocks

Get PRO

Need premium blocks and templates? Upgrade to PRO and get access.

Upgrade
JoinLogin
Presets
Monochrome
Overview
  • Introduction
  • Components
  • Installation
Components
  • Accordion
  • Alert
  • Alert Dialog
  • Aspect Ratio
  • Avatar
  • Badge
  • Breadcrumb
  • Button
  • Button Group
  • CalendarNEW
  • Card
  • CarouselNEW
  • Checkbox
  • Collapsible
  • Dialog
  • Dropdown Menu
  • Empty
  • Field
  • Input
  • Input Group
  • Item
  • Kbd
  • Label
  • Native Select
  • Scroll Area
  • SelectNEW
  • Separator
  • SwitchNEW
  • Table
  • Tabs
  • Textarea
  • TooltipNEW

Empty

PreviousNext

Use the Empty component to display an empty state.

1import { Button } from "@/components/ui/button";2import {3  Empty,4  EmptyContent,

Installation

pnpm dlx sprawlify@latest add empty
npx sprawlify@latest add empty
yarn sprawlify@latest add empty
bunx --bun sprawlify@latest add empty

Install the following dependencies:

pnpm add @sprawlify/primitives @sprawlify/react
npm install @sprawlify/primitives @sprawlify/react
yarn add @sprawlify/primitives @sprawlify/react
bun add @sprawlify/primitives @sprawlify/react

Add the following files to your project:

empty.tsx
1"use client";23import { cva, type VariantProps } from "class-variance-authority";4import { cn } from "@/lib/utils";5import { sprawlify } from "@sprawlify/react";67function Empty({ className, ...props }: React.ComponentProps<typeof sprawlify.div>) {8  return (9    <sprawlify.div10      data-scope="empty"11      data-part="root"12      data-slot="empty"13      className={cn(14        "gap-4 rounded-xl border-dashed p-6 flex w-full min-w-0 flex-1 flex-col items-center justify-center text-center text-balance",15        className,16      )}17      {...props}18    />19  );20}2122function EmptyHeader({ className, ...props }: React.ComponentProps<typeof sprawlify.div>) {23  return (24    <sprawlify.div25      data-slot="empty-header"26      className={cn("gap-2 flex max-w-sm flex-col items-center", className)}27      {...props}28    />29  );30}3132const emptyMediaVariants = cva(33  "mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0",34  {35    variants: {36      variant: {37        default: "bg-transparent",38        icon: "bg-muted text-foreground flex size-8 shrink-0 items-center justify-center rounded-lg [&_svg:not([class*='size-'])]:size-4",39      },40    },41    defaultVariants: {42      variant: "default",43    },44  },45);4647function EmptyMedia({48  className,49  variant = "default",50  ...props51}: React.ComponentProps<typeof sprawlify.div> & VariantProps<typeof emptyMediaVariants>) {52  return (53    <sprawlify.div54      data-slot="empty-icon"55      data-variant={variant}56      className={cn(emptyMediaVariants({ variant, className }))}57      {...props}58    />59  );60}6162function EmptyTitle({ className, ...props }: React.ComponentProps<typeof sprawlify.div>) {63  return (64    <sprawlify.div65      data-slot="empty-title"66      className={cn("text-sm font-medium tracking-tight", className)}67      {...props}68    />69  );70}7172function EmptyDescription({ className, ...props }: React.ComponentProps<typeof sprawlify.p>) {73  return (74    <sprawlify.p75      data-slot="empty-description"76      className={cn(77        "text-sm/relaxed text-muted-foreground [&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4",78        className,79      )}80      {...props}81    />82  );83}8485function EmptyContent({ className, ...props }: React.ComponentProps<typeof sprawlify.div>) {86  return (87    <sprawlify.div88      data-slot="empty-content"89      className={cn(90        "gap-2.5 text-sm flex w-full max-w-sm min-w-0 flex-col items-center text-balance",91        className,92      )}93      {...props}94    />95  );96}9798export { Empty, EmptyHeader, EmptyTitle, EmptyDescription, EmptyContent, EmptyMedia };99

Update the import paths to match your project setup.

Usage

1import {
2  Empty,
3  EmptyHeader,
4  EmptyTitle,
5  EmptyDescription,
6  EmptyContent,
7  EmptyMedia
8} from "@/components/ui/empty"
1<Empty>
2  <EmptyHeader>
3    <EmptyMedia variant="icon">
4      <Icon />
5    </EmptyMedia>
6    <EmptyTitle>No data</EmptyTitle>
7    <EmptyDescription>No data found</EmptyDescription>
8  </EmptyHeader>
9  <EmptyContent>
10    <Button>Add data</Button>
11  </EmptyContent>
12</Empty>

Examples

Avatar

Use the EmptyMedia component to display an avatar in the empty state.

1import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";2import { Button } from "@/components/ui/button";3import {4  Empty,

Avatar Group

Use the EmptyMedia component to display an avatar group in the empty state.

1import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";2import { Button } from "@/components/ui/button";3import {4  Empty,

Background

Use the bg-* and bg-gradient-* utilities to add a background to the empty state.

1import { Button } from "@/components/ui/button";2import {3  Empty,4  EmptyContent,

Outline

Use the border utility class to create an outline empty state.

1import { Button } from "@/components/ui/button";2import {3  Empty,4  EmptyContent,

On This Page

InstallationUsageExamplesAvatarAvatar GroupBackgroundOutline

Get PRO

Need premium blocks and templates? Upgrade to PRO and get access.