--- title: Item description: A versatile component that you can use to display any content. component: true --- The `Item` component is a straightforward flex container that can house nearly any type of content. Use it to display a title, description, and actions. Group it with the `ItemGroup` component to create a list of items. You can pretty much achieve the same result with the `div` element and some classes, but **I've built this so many times** that I decided to create a component for it. Now I use it all the time. ## Installation CLI Manual ```bash npx shadcn@latest add item ``` Copy and paste the following code into your project. Update the import paths to match your project setup. ## Usage ```tsx showLineNumbers import { Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemHeader, ItemMedia, ItemTitle, } from "@/components/ui/item" ``` ```tsx showLineNumbers Item Header Item Item Item Footer ``` ## Item vs Field Use `Field` if you need to display a form input such as a checkbox, input, radio, or select. If you only need to display content such as a title, description, and actions, use `Item`. ## Examples ### Variants ### Size The `Item` component has different sizes for different use cases. For example, you can use the `sm` size for a compact item or the `default` size for a standard item. ### Icon ### Avatar ### Image ### Group ### Header ### Link To render an item as a link, use the `asChild` prop. The hover and focus states will be applied to the anchor element. ```tsx showLineNumbers Dashboard Overview of your account and activity. ``` ### Dropdown ## API Reference ### Item The main component for displaying content with media, title, description, and actions. | Prop | Type | Default | | --------- | ----------------------------------- | ----------- | | `variant` | `"default" \| "outline" \| "muted"` | `"default"` | | `size` | `"default" \| "sm"` | `"default"` | | `asChild` | `boolean` | `false` | ```tsx Item Item ``` You can use the `asChild` prop to render a custom component as the item, for example a link. The hover and focus states will be applied to the custom component. ```tsx showLineNumbers import { Item, ItemContent, ItemDescription, ItemMedia, ItemTitle, } from "@/components/ui/item" export function ItemLink() { return ( Dashboard Overview of your account and activity. ) } ``` ### ItemGroup The `ItemGroup` component is a container that groups related items together with consistent styling. | Prop | Type | Default | | ----------- | -------- | ------- | | `className` | `string` | | ```tsx ``` ### ItemSeparator The `ItemSeparator` component is a separator that separates items in the item group. | Prop | Type | Default | | ----------- | -------- | ------- | | `className` | `string` | | ```tsx ``` ### ItemMedia Use the `ItemMedia` component to display media content such as icons, images, or avatars. | Prop | Type | Default | | ----------- | -------------------------------- | ----------- | | `variant` | `"default" \| "icon" \| "image"` | `"default"` | | `className` | `string` | | ```tsx ``` ```tsx ... ``` ### ItemContent The `ItemContent` component wraps the title and description of the item. You can skip `ItemContent` if you only need a title. | Prop | Type | Default | | ----------- | -------- | ------- | | `className` | `string` | | ```tsx Item Item ``` ### ItemTitle Use the `ItemTitle` component to display the title of the item. | Prop | Type | Default | | ----------- | -------- | ------- | | `className` | `string` | | ```tsx Item Title ``` ### ItemDescription Use the `ItemDescription` component to display the description of the item. | Prop | Type | Default | | ----------- | -------- | ------- | | `className` | `string` | | ```tsx Item description ``` ### ItemActions Use the `ItemActions` component to display action buttons or other interactive elements. | Prop | Type | Default | | ----------- | -------- | ------- | | `className` | `string` | | ```tsx ``` ### ItemHeader Use the `ItemHeader` component to display a header in the item. | Prop | Type | Default | | ----------- | -------- | ------- | | `className` | `string` | | ```tsx Item Header ``` ### ItemFooter Use the `ItemFooter` component to display a footer in the item. | Prop | Type | Default | | ----------- | -------- | ------- | | `className` | `string` | | ```tsx Item Footer ```