All componentsdisplay
Empty State
No messages yet
When someone sends you a message, it'll show up here.
Installation
$ npx shadcn@latest add https://deepmoon.dev/r/empty-state.jsonProps
EmptyStateProps
| Prop | Type | Required |
|---|---|---|
| icon | React.ReactNode | No |
| title | React.ReactNode | Yes |
| description | React.ReactNode | No |
| action | React.ReactNode | No |
Code
empty-state.tsx
import * as React from "react";
import { cn } from "@/lib/utils";
export interface EmptyStateProps extends Omit<React.ComponentPropsWithoutRef<"div">, "title"> {
icon?: React.ReactNode;
title: React.ReactNode;
description?: React.ReactNode;
action?: React.ReactNode;
}
export function EmptyState({ icon, title, description, action, className, ...props }: EmptyStateProps) {
return (
<div
className={cn(
"flex flex-col items-center justify-center gap-3 rounded-lg border border-dashed border-border p-10 text-center",
className,
)}
{...props}
>
{icon ? (
<div className="text-muted-foreground" aria-hidden="true">
{icon}
</div>
) : null}
<div className="flex flex-col gap-1">
<p className="text-sm font-semibold text-foreground">{title}</p>
{description ? <p className="text-sm text-muted-foreground">{description}</p> : null}
</div>
{action ? <div className="mt-2">{action}</div> : null}
</div>
);
}