ריק
מקום שמור לחיפושים ללא תוצאות, לוחות מחוונים ריקים ומסכי הפעלה ראשונית — סמל, כותרת ופעולה הממוסגרים במסגרת בסגנון ניאו-ברוטליסטי.
import { IconFolderCode } from "@tabler/icons-react"
import { ArrowUpRightIcon } from "lucide-react"
מצב ה-empty ממלא את הפער כשאין מה לרנדר — חריץ לאייקון או avatar, כותרת, תיאור וקריאה לפעולה. זו קבוצת divs להרכבה בלי תלויות (בלי פרימיטיב מתחת), מעוצבת לפי המתכון הנאו-ברוטליסטי: מסגרות עבות וטיפוגרפיית כותרת מודגשת.
השתמשו בו כש:
- חיפושים ומסננים בלי תוצאות — מסבירים למה הרשימה ריקה ומציעים דרך לאפס או להרחיב את השאילתה.
- מסכי הרצה ראשונה — "עדיין אין פרויקטים" עם כפתור יצירה שמצביע על הצעד הבא.
- תיבות דואר ותורים שרוקנו — מאשרים שהרשימה הריקה היא הצלחה, לא שגיאה.
התקנה#
pnpm dlx shadcn@latest add https://neobrutalism.com/r/base/empty.jsonnpx shadcn@latest add https://neobrutalism.com/r/base/empty.jsonyarn dlx shadcn@latest add https://neobrutalism.com/r/base/empty.jsonbunx --bun shadcn@latest add https://neobrutalism.com/r/base/empty.json
העתיקו והדביקו את הקוד הבא לתוך הפרויקט שלכם.
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "@/lib/utils"
function Empty({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="empty"
className={cn(
"flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 rounded border-2 bg-card p-6 text-center text-balance",
className
)}
{...props}
/>
)
}
function EmptyHeader({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="empty-header"
className={cn("flex max-w-sm flex-col items-center gap-2", className)}
{...props}
/>
)
}
const emptyMediaVariants = cva(
"mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0",
{
variants: {
variant: {
default: "bg-transparent",
icon: "flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted text-foreground [&_svg:not([class*='size-'])]:size-4",
},
},
defaultVariants: {
variant: "default",
},
}
)
function EmptyMedia({
className,
variant = "default",
...props
}: React.ComponentProps<"div"> & VariantProps<typeof emptyMediaVariants>) {
return (
<div
data-slot="empty-icon"
data-variant={variant}
className={cn(emptyMediaVariants({ variant, className }))}
{...props}
/>
)
}
function EmptyTitle({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="empty-title"
className={cn(
"cn-font-heading text-sm font-medium tracking-tight",
className
)}
{...props}
/>
)
}
function EmptyDescription({ className, ...props }: React.ComponentProps<"p">) {
return (
<div
data-slot="empty-description"
className={cn(
"text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",
className
)}
{...props}
/>
)
}
function EmptyContent({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="empty-content"
className={cn(
"flex w-full max-w-sm min-w-0 flex-col items-center gap-2.5 text-sm text-balance",
className
)}
{...props}
/>
)
}
export {
Empty,
EmptyHeader,
EmptyTitle,
EmptyDescription,
EmptyContent,
EmptyMedia,
}
עדכנו את נתיבי הייבוא כך שיתאימו למבנה הפרויקט שלכם.
שימוש#
import {
Empty,
EmptyContent,
EmptyDescription,
EmptyHeader,
EmptyMedia,
EmptyTitle,
} from "@/components/ui/empty"<Empty>
<EmptyHeader>
<EmptyMedia variant="icon">
<Icon />
</EmptyMedia>
<EmptyTitle>No data</EmptyTitle>
<EmptyDescription>No data found</EmptyDescription>
</EmptyHeader>
<EmptyContent>
<Button>Add data</Button>
</EmptyContent>
</Empty>קומפוזיציה#
השתמשו בקומפוזיציה הבאה כדי לבנות מצב Empty:
Empty
├── EmptyHeader
│ ├── EmptyMedia
│ ├── EmptyTitle
│ └── EmptyDescription
└── EmptyContentדוגמאות#
מתאר#
השתמשו במחלקת העזר border כדי ליצור מצב ריק עם מתאר.
import { IconCloud } from "@tabler/icons-react"
import { Button } from "@/components/ui/button"רקע#
השתמשו בכלי העזר bg-* ו-bg-gradient-* כדי להוסיף רקע למצב הריק.
import { IconBell } from "@tabler/icons-react"
import { RefreshCcwIcon } from "lucide-react"
Avatar#
השתמשו ברכיב EmptyMedia כדי להציג אווטאר במצב הריק.
import {
Avatar,
AvatarFallback,קבוצת Avatar#
השתמשו ברכיב EmptyMedia כדי להציג קבוצת אווטארים במצב הריק.
import { PlusIcon } from "lucide-react"
import {InputGroup#
אפשר להוסיף רכיב InputGroup לרכיב EmptyContent.
import { SearchIcon } from "lucide-react"
import {RTL#
כדי להפעיל RTL ב-Neobrutalism, עיינו במדריך ההגדרה של RTL.
"use client"
import * as React from "react"נגישות#
מצב ה-empty הוא מצגתי — divs רגילים בלי roles או התנהגות מקלדת, כך שאין מה לחבר. סמנו אייקון EmptyMedia דקורטיבי בלבד עם aria-hidden="true", והשאירו פעולות ב-EmptyContent כאלמנטי Button או קישור אמיתיים כדי שיישארו ניתנים לפוקוס. כשמצב הריק מחליף תוכן אחרי פעולה אסינכרונית (חיפוש שחוזר בלי תוצאות), הכריזו עליו דרך אזור live — החלפת ה-DOM עצמה שקטה לקוראי מסך.
תיעוד ה-API#
Empty#
הרכיב המרכזי של המצב הריק. עוטף את הרכיבים EmptyHeader ו-EmptyContent.
| Prop | Type | Default |
|---|---|---|
className | string |
<Empty>
<EmptyHeader />
<EmptyContent />
</Empty>EmptyHeader#
רכיב EmptyHeader עוטף את המדיה, הכותרת והתיאור של המצב הריק.
| Prop | Type | Default |
|---|---|---|
className | string |
<EmptyHeader>
<EmptyMedia />
<EmptyTitle />
<EmptyDescription />
</EmptyHeader>EmptyMedia#
השתמשו ברכיב EmptyMedia כדי להציג את המדיה של המצב הריק, כמו אייקון או תמונה. אפשר להשתמש בו גם כדי להציג רכיבים אחרים, כמו אווטאר.
| Prop | Type | Default |
|---|---|---|
variant | "default" | "icon" | default |
className | string |
<EmptyMedia variant="icon">
<Icon />
</EmptyMedia><EmptyMedia>
<Avatar>
<AvatarImage src="..." />
<AvatarFallback>CN</AvatarFallback>
</Avatar>
</EmptyMedia>EmptyTitle#
השתמשו ברכיב EmptyTitle כדי להציג את כותרת המצב הריק.
| Prop | Type | Default |
|---|---|---|
className | string |
<EmptyTitle>No data</EmptyTitle>EmptyDescription#
השתמשו ברכיב EmptyDescription כדי להציג את תיאור המצב הריק.
| Prop | Type | Default |
|---|---|---|
className | string |
<EmptyDescription>You do not have any notifications.</EmptyDescription>EmptyContent#
השתמשו ברכיב EmptyContent כדי להציג את תוכן המצב הריק, כמו כפתור, שדה קלט או קישור.
| Prop | Type | Default |
|---|---|---|
className | string |
<EmptyContent>
<Button>Add Project</Button>
</EmptyContent>