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.
A simple item with title and description.
Installation
Copy and paste the component source files linked at the top of this page into your project.
Usage
<script lang="ts">
import * as Item from "$lib/components/ui/item/index.js";
</script>
<Item.Root>
<Item.Header>Item Header</Item.Header>
<Item.Media />
<Item.Content>
<Item.Title>Item</Item.Title>
<Item.Description>Item</Item.Description>
</Item.Content>
<Item.Actions />
<Item.Footer>Item Footer</Item.Footer>
</Item.Root> 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
Standard styling with subtle background and borders.
Outlined style with clear borders and transparent background.
Subdued appearance with muted colors for secondary content.
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.
A simple item with title and description.
Icon
New login detected from unknown device.
Avatar
Last seen 5 months ago
Invite your team to collaborate on this project.
Image
Group
shadcn@vercel.com
maxleiter@vercel.com
evilrabbit@vercel.com
Header
Everyday tasks and UI generation.
Advanced thinking or reasoning.
Open Source model for everyone.
Link
To render an item as a link, use the the child snippet. The hover and focus states will be applied to the anchor element.