आइटम
मीडिया, शीर्षक, विवरण और क्रिया स्लॉट्स के साथ एक फ्लेक्स रो, जो सूचना फ़ीड, सेटिंग्स सूचियों और फ़ाइल रो के लिए है — नियोब्रुटलिस्ट शैली में।
import { BadgeCheckIcon, ChevronRightIcon } from "lucide-react"
import { Button } from "@/components/ui/button"आइटम नामित स्लॉट — media, content, actions — वाला flex पंक्ति है, हर ऐप में आने वाले "list of things" पैटर्न के लिए। नीचे कोई headless प्रिमिटिव नहीं, सिर्फ़ स्टाइल किए एलिमेंट (Base UI के useRender render prop के लिए), नियोब्रूटलिस्ट रेसिपी में: 2px बॉर्डर — outline वैरिएंट पर दिखता — और कठोर ऑफ़सेट फ़ोकस रिंग।
इसे इन स्थितियों में चुनें:
- नोटिफ़िकेशन और एक्टिविटी फ़ीड — प्रति पंक्ति अवतार, संदेश, टाइमस्टैम्प, और dismiss या एक्शन बटन।
- सेटिंग्स और इंटीग्रेशन सूची — आइकन, नाम, स्टेटस पंक्ति, पीछे किनारे पर स्विच या बटन।
- फ़ाइल ब्राउज़र और सर्च रिज़ल्ट — थंबनेल या आइकन प्लस मेटाडेटा; पूरी पंक्ति
renderसे लिंक।
Item कंपोनेंट एक सरल flex कंटेनर है जो लगभग किसी भी प्रकार की सामग्री रख सकता है. इसका उपयोग शीर्षक, विवरण और क्रियाएँ दिखाने के लिए करें. आइटम की सूची बनाने के लिए इसे ItemGroup कंपोनेंट के साथ समूहित करें.
इंस्टॉलेशन#
pnpm dlx shadcn@latest add https://neobrutalism.com/r/base/item.jsonnpx shadcn@latest add https://neobrutalism.com/r/base/item.jsonyarn dlx shadcn@latest add https://neobrutalism.com/r/base/item.jsonbunx --bun shadcn@latest add https://neobrutalism.com/r/base/item.json
निम्नलिखित कोड को अपने प्रोजेक्ट में कॉपी और पेस्ट करें.
import * as React from "react"
import { cva, type VariantProps } from "class-variance-authority"
import { Slot } from "radix-ui"
import { cn } from "@/lib/utils"
import { Separator } from "@/components/ui/separator"
function ItemGroup({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
role="list"
data-slot="item-group"
className={cn(
"group/item-group flex w-full flex-col gap-4 has-data-[size=sm]:gap-2.5 has-data-[size=xs]:gap-2",
className
)}
{...props}
/>
)
}
function ItemSeparator({
className,
...props
}: React.ComponentProps<typeof Separator>) {
return (
<Separator
data-slot="item-separator"
orientation="horizontal"
className={cn("my-2", className)}
{...props}
/>
)
}
const itemVariants = cva(
"group/item flex w-full flex-wrap items-center rounded border-2 text-sm transition-colors duration-100 outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary [a]:transition-colors [a]:hover:bg-accent",
{
variants: {
variant: {
default: "border-transparent",
outline: "border-border",
muted: "border-transparent bg-muted/50",
},
size: {
default: "gap-2.5 px-3 py-2.5",
sm: "gap-2.5 px-3 py-2.5",
xs: "gap-2 px-2.5 py-2 in-data-[slot=dropdown-menu-content]:p-0",
},
},
defaultVariants: {
variant: "default",
size: "default",
},
}
)
function Item({
className,
variant = "default",
size = "default",
asChild = false,
...props
}: React.ComponentProps<"div"> &
VariantProps<typeof itemVariants> & { asChild?: boolean }) {
const Comp = asChild ? Slot.Root : "div"
return (
<Comp
data-slot="item"
data-variant={variant}
data-size={size}
className={cn(itemVariants({ variant, size, className }))}
{...props}
/>
)
}
const itemMediaVariants = cva(
"flex shrink-0 items-center justify-center gap-2 group-has-data-[slot=item-description]/item:translate-y-0.5 group-has-data-[slot=item-description]/item:self-start [&_svg]:pointer-events-none",
{
variants: {
variant: {
default: "bg-transparent",
icon: "[&_svg:not([class*='size-'])]:size-4",
image:
"size-10 overflow-hidden rounded-sm group-data-[size=sm]/item:size-8 group-data-[size=xs]/item:size-6 [&_img]:size-full [&_img]:object-cover",
},
},
defaultVariants: {
variant: "default",
},
}
)
function ItemMedia({
className,
variant = "default",
...props
}: React.ComponentProps<"div"> & VariantProps<typeof itemMediaVariants>) {
return (
<div
data-slot="item-media"
data-variant={variant}
className={cn(itemMediaVariants({ variant, className }))}
{...props}
/>
)
}
function ItemContent({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="item-content"
className={cn(
"flex flex-1 flex-col gap-1 group-data-[size=xs]/item:gap-0 [&+[data-slot=item-content]]:flex-none",
className
)}
{...props}
/>
)
}
function ItemTitle({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="item-title"
className={cn(
"line-clamp-1 flex w-fit items-center gap-2 text-sm leading-snug font-medium underline-offset-4",
className
)}
{...props}
/>
)
}
function ItemDescription({ className, ...props }: React.ComponentProps<"p">) {
return (
<p
data-slot="item-description"
className={cn(
"line-clamp-2 text-left text-sm leading-normal font-normal text-muted-foreground group-data-[size=xs]/item:text-xs [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",
className
)}
{...props}
/>
)
}
function ItemActions({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="item-actions"
className={cn("flex items-center gap-2", className)}
{...props}
/>
)
}
function ItemHeader({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="item-header"
className={cn(
"flex basis-full items-center justify-between gap-2",
className
)}
{...props}
/>
)
}
function ItemFooter({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="item-footer"
className={cn(
"flex basis-full items-center justify-between gap-2",
className
)}
{...props}
/>
)
}
export {
Item,
ItemMedia,
ItemContent,
ItemActions,
ItemGroup,
ItemSeparator,
ItemTitle,
ItemDescription,
ItemHeader,
ItemFooter,
}
अपने प्रोजेक्ट सेटअप के अनुसार इंपोर्ट पाथ अपडेट करें.
उपयोग#
import {
Item,
ItemActions,
ItemContent,
ItemDescription,
ItemMedia,
ItemTitle,
} from "@/components/ui/item"<Item>
<ItemMedia variant="icon">
<Icon />
</ItemMedia>
<ItemContent>
<ItemTitle>Title</ItemTitle>
<ItemDescription>Description</ItemDescription>
</ItemContent>
<ItemActions>
<Button>Action</Button>
</ItemActions>
</Item>कंपोज़िशन#
Item बनाने के लिए निम्नलिखित कंपोज़िशन का उपयोग करें:
ItemGroup
└── Item
├── ItemHeader
├── ItemMedia
├── ItemContent
│ ├── ItemTitle
│ └── ItemDescription
├── ItemActions
└── ItemFooterItem vs Field#
यदि आपको चेकबॉक्स, इनपुट, रेडियो या select जैसा कोई फ़ॉर्म इनपुट दिखाना हो तो Field का उपयोग करें.
यदि आपको केवल शीर्षक, विवरण और क्रियाओं जैसी सामग्री दिखानी है, तो Item का उपयोग करें.
Variant#
आइटम की विज़ुअल शैली बदलने के लिए variant prop का उपयोग करें.
import { InboxIcon } from "lucide-react"
import {Size#
आइटम का आकार बदलने के लिए size prop का उपयोग करें. उपलब्ध आकार default, sm और xs हैं.
import { InboxIcon } from "lucide-react"
import {उदाहरण#
आइकन#
आइकन दिखाने के लिए variant="icon" के साथ ItemMedia का उपयोग करें.
import { ShieldAlertIcon } from "lucide-react"
import { Button } from "@/components/ui/button"Avatar#
आप अवतार दिखाने के लिए variant="avatar" के साथ ItemMedia का उपयोग कर सकते हैं.
import { Plus } from "lucide-react"
import {इमेज#
इमेज दिखाने के लिए variant="image" के साथ ItemMedia का उपयोग करें.
import Image from "next/image"
import {समूह#
संबंधित आइटम को एक साथ समूहित करने के लिए ItemGroup का उपयोग करें.
import * as React from "react"
import { PlusIcon } from "lucide-react"
शीर्षक#
आइटम सामग्री के ऊपर शीर्षक जोड़ने के लिए ItemHeader का उपयोग करें.
import Image from "next/image"
import {लिंक#
आइटम को लिंक के रूप में रेंडर करने के लिए render prop का उपयोग करें. hover और focus स्थितियाँ anchor एलिमेंट पर लागू होंगी.
import { ChevronRightIcon, ExternalLinkIcon } from "lucide-react"
import {<Item render={<a href="/dashboard" />}>
<ItemMedia variant="icon">
<HomeIcon />
</ItemMedia>
<ItemContent>
<ItemTitle>Dashboard</ItemTitle>
<ItemDescription>Overview of your account and activity.</ItemDescription>
</ItemContent>
</Item>Dropdown#
"use client"
import { ChevronDownIcon } from "lucide-react"RTL#
Neobrutalism में RTL समर्थन सक्षम करने के लिए, RTL कॉन्फ़िगरेशन गाइड देखें.
"use client"
import * as React from "react"एक्सेसिबिलिटी#
आइटम प्रेजेंटेशनल है — स्टाइल किए एलिमेंट, अपनी कोई ARIA वायरिंग नहीं; हाँ ItemGroup role="list" रेंडर करता है (अगर सूची संरचना घोषित होनी चाहिए तो हर Item पर role="listitem" जोड़ें)। इंटरैक्टिव पंक्तियों के लिए div पर click handler न लगाएँ — render prop से असली <a> या <button> रेंडर करें ताकि नेटिव फ़ोकस और कीबोर्ड व्यवहार मिले; दिखने वाली फ़ोकस रिंग पहले से स्टाइल है। सजावटी आइकन मीडिया aria-hidden करें और इमेज मीडिया को सार्थक alt दें।
API रेफ़रेंस#
Item#
मीडिया, शीर्षक, विवरण और क्रियाओं के साथ सामग्री दिखाने के लिए मुख्य कंपोनेंट.
| Prop | Type | Default |
|---|---|---|
variant | "default" | "outline" | "muted" | "default" |
size | "default" | "sm" | "xs" | "default" |
render | React.ReactElement |
ItemGroup#
एक कंटेनर जो संबंधित आइटम को एक समान स्टाइल के साथ समूहित करता है.
<ItemGroup>
<Item />
<Item />
</ItemGroup>ItemSeparator#
किसी समूह के आइटम के बीच एक विभाजक.
<ItemGroup>
<Item />
<ItemSeparator />
<Item />
</ItemGroup>ItemMedia#
आइकन, इमेज या अवतार जैसी मीडिया सामग्री दिखाने के लिए ItemMedia का उपयोग करें.
| Prop | Type | Default |
|---|---|---|
variant | "default" | "icon" | "image" | "default" |
<ItemMedia variant="icon">
<Icon />
</ItemMedia><ItemMedia variant="image">
<img src="..." alt="..." />
</ItemMedia>ItemContent#
आइटम के शीर्षक और विवरण को लपेटता है.
<ItemContent>
<ItemTitle>Title</ItemTitle>
<ItemDescription>Description</ItemDescription>
</ItemContent>ItemTitle#
आइटम का शीर्षक दिखाता है.
<ItemTitle>Item Title</ItemTitle>ItemDescription#
आइटम का विवरण दिखाता है.
<ItemDescription>Item description</ItemDescription>ItemActions#
क्रिया बटनों या अन्य इंटरैक्टिव एलिमेंट के लिए कंटेनर.
<ItemActions>
<Button>Action</Button>
</ItemActions>ItemHeader#
आइटम सामग्री के ऊपर एक शीर्षक दिखाता है.
<Item>
<ItemHeader>Header</ItemHeader>
<ItemContent>...</ItemContent>
</Item>ItemFooter#
आइटम सामग्री के नीचे एक फ़ुटर दिखाता है.
<Item>
<ItemContent>...</ItemContent>
<ItemFooter>Footer</ItemFooter>
</Item>