empty
shadcn/emptyFreeComponent
shadcn publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by shadcn on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add emptySource
1import { cva, type VariantProps } from "class-variance-authority"23import { cn } from "@/lib/utils"45function Empty({ className, ...props }: React.ComponentProps<"div">) {6 return (7 <div8 data-slot="empty"9 className={cn(10 "flex min-w-0 flex-1 flex-col items-center justify-center gap-6 text-balance rounded-lg border-dashed p-6 text-center md:p-12",11 className12 )}13 {...props}14 />15 )16}1718function EmptyHeader({ className, ...props }: React.ComponentProps<"div">) {19 return (20 <div21 data-slot="empty-header"22 className={cn(23 "flex max-w-sm flex-col items-center gap-2 text-center",24 className25 )}26 {...props}27 />28 )29}3031const emptyMediaVariants = cva(32 "mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0",33 {34 variants: {35 variant: {36 default: "bg-transparent",37 icon: "bg-muted text-foreground flex size-10 shrink-0 items-center justify-center rounded-lg [&_svg:not([class*='size-'])]:size-6",38 },39 },40 defaultVariants: {41 variant: "default",42 },43 }44)4546function EmptyMedia({47 className,48 variant = "default",49 ...props50}: React.ComponentProps<"div"> & VariantProps<typeof emptyMediaVariants>) {51 return (52 <div53 data-slot="empty-icon"54 data-variant={variant}55 className={cn(emptyMediaVariants({ variant, className }))}56 {...props}57 />58 )59}6061function EmptyTitle({ className, ...props }: React.ComponentProps<"div">) {62 return (63 <div64 data-slot="empty-title"65 className={cn("text-lg font-medium tracking-tight", className)}66 {...props}67 />68 )69}7071function EmptyDescription({ className, ...props }: React.ComponentProps<"p">) {72 return (73 <div74 data-slot="empty-description"75 className={cn(76 "text-muted-foreground [&>a:hover]:text-primary text-sm/relaxed [&>a]:underline [&>a]:underline-offset-4",77 className78 )}79 {...props}80 />81 )82}8384function EmptyContent({ className, ...props }: React.ComponentProps<"div">) {85 return (86 <div87 data-slot="empty-content"88 className={cn(89 "flex w-full min-w-0 max-w-sm flex-col items-center gap-4 text-balance text-sm",90 className91 )}92 {...props}93 />94 )95}9697export {98 Empty,99 EmptyHeader,100 EmptyTitle,101 EmptyDescription,102 EmptyContent,103 EmptyMedia,104}
Files it writes
More from shadcn
All 62 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | shadcn | Components | Free | no deps | |
| alertalert | shadcn | Components | Free | no deps | |
| alert-dialogalert-dialog | shadcn | Components | Free | no deps | |
| aspect-ratioaspect-ratio | shadcn | Components | Free | no deps | |
| attachmentattachment | shadcn | Components | Free | no deps | |
| avataravatar | shadcn | Components | Free | no deps | |
| badgebadge | shadcn | Components | Free | no deps | |
| breadcrumbbreadcrumb | shadcn | Components | Free | no deps |
