Item
A versatile component for displaying content with media, title, description, and actions.
A simple item with title and description.
// Inline SVG icons from Lucide (https://lucide.dev), ISC License, Copyright (c) Lucide Icons and Contributors.
import { Button } from "~/components/ui/button"
import {
Item,
ItemActions,
ItemContent,
ItemDescription,
ItemMedia,
ItemTitle
} from "~/components/ui/item"
export default function ItemDemo() {
return (
<div class="flex w-full max-w-md flex-col gap-6">
<Item variant="outline">
<ItemContent>
<ItemTitle>Basic Item</ItemTitle>
<ItemDescription>
A simple item with title and description.
</ItemDescription>
</ItemContent>
<ItemActions>
<Button size="sm" variant="outline">
Action
</Button>
</ItemActions>
</Item>
<Item as="a" href="#" size="sm" variant="outline">
<ItemMedia variant="icon">
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-5"
>
<path d="M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z" />
<path d="m16 9-5.5 5.5L8 12" />
</svg>
</ItemMedia>
<ItemContent>
<ItemTitle>Your profile has been verified.</ItemTitle>
</ItemContent>
<ItemActions>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
>
<path d="m9 18 6-6-6-6" />
</svg>
</ItemActions>
</Item>
</div>
)
}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.
Installation
Install the following dependencies:
Install the required Solid UI dependencies:
Copy and paste the following code into your project.
import {
dynamic,
type ComponentProps,
type JSX,
type ValidComponent
} from "@solidjs/web"
import { cva, type VariantProps } from "class-variance-authority"
import { isStatic, merge, omit } from "solid-js"
import { cn } from "~/lib/utils"
import { Separator, type SeparatorProps } from "~/components/ui/separator"
type ItemGroupProps = ComponentProps<"div">
const ItemGroup = (props: ItemGroupProps) => (
<div
data-slot="item-group"
role="list"
{...props}
class={cn(
"group/item-group gap-4 has-data-[size=sm]:gap-2.5 has-data-[size=xs]:gap-2 flex w-full flex-col",
props.class
)}
/>
)
type ItemSeparatorProps = SeparatorProps
const ItemSeparator = (props: ItemSeparatorProps) => (
<Separator
data-slot="item-separator"
orientation="horizontal"
{...props}
class={cn("my-2", props.class)}
/>
)
const itemVariants = cva(
"group/item rounded-lg border text-sm [a]:hover:bg-muted flex w-full flex-wrap items-center transition-colors duration-100 outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 [a]:transition-colors",
{
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=menu-content]:p-0"
}
},
defaultVariants: {
variant: "default",
size: "default"
}
}
)
type ItemProps<T extends ValidComponent = "div"> = {
as?: T
class?: string | undefined
children?: JSX.Element
} & VariantProps<typeof itemVariants> &
Omit<ComponentProps<T>, "as" | "class" | "children">
const Item = <T extends ValidComponent = "div">(rawProps: ItemProps<T>) => {
const local = merge(
{ as: "div" as T, variant: "default", size: "default" } as const,
rawProps
) as ItemProps
const others = omit(rawProps as ItemProps, "as", "class", "variant", "size")
const Comp = dynamic(() => local.as ?? "div", {
static: isStatic(rawProps, "as")
})
return (
<Comp
class={cn(
itemVariants({ variant: local.variant, size: local.size }),
local.class
)}
data-size={local.size}
data-slot="item"
data-variant={local.variant}
{...others}
/>
)
}
const itemMediaVariants = cva(
"gap-2 group-has-data-[slot=item-description]/item:translate-y-0.5 group-has-data-[slot=item-description]/item:self-start flex shrink-0 items-center justify-center [&_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"
}
}
)
type ItemMediaProps = ComponentProps<"div"> &
VariantProps<typeof itemMediaVariants>
const ItemMedia = (rawProps: ItemMediaProps) => {
const local = merge({ variant: "default" } as const, rawProps)
const others = omit(rawProps, "class", "variant")
return (
<div
class={cn(itemMediaVariants({ variant: local.variant }), local.class)}
data-slot="item-media"
data-variant={local.variant}
{...others}
/>
)
}
type ItemContentProps = ComponentProps<"div">
const ItemContent = (props: ItemContentProps) => (
<div
data-slot="item-content"
{...props}
class={cn(
"gap-1 group-data-[size=xs]/item:gap-0 flex flex-1 flex-col [&+[data-slot=item-content]]:flex-none",
props.class
)}
/>
)
type ItemTitleProps = ComponentProps<"div">
const ItemTitle = (props: ItemTitleProps) => (
<div
data-slot="item-title"
{...props}
class={cn(
"gap-2 text-sm leading-snug font-medium underline-offset-4 line-clamp-1 flex w-fit items-center",
props.class
)}
/>
)
type ItemDescriptionProps = ComponentProps<"p">
const ItemDescription = (props: ItemDescriptionProps) => (
<p
data-slot="item-description"
{...props}
class={cn(
"text-left text-sm leading-normal text-muted-foreground group-data-[size=xs]/item:text-xs line-clamp-2 font-normal [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",
props.class
)}
/>
)
type ItemActionsProps = ComponentProps<"div">
const ItemActions = (props: ItemActionsProps) => (
<div
data-slot="item-actions"
{...props}
class={cn("gap-2 flex items-center", props.class)}
/>
)
type ItemHeaderProps = ComponentProps<"div">
const ItemHeader = (props: ItemHeaderProps) => (
<div
data-slot="item-header"
{...props}
class={cn(
"gap-2 flex basis-full items-center justify-between",
props.class
)}
/>
)
type ItemFooterProps = ComponentProps<"div">
const ItemFooter = (props: ItemFooterProps) => (
<div
data-slot="item-footer"
{...props}
class={cn(
"gap-2 flex basis-full items-center justify-between",
props.class
)}
/>
)
export {
Item,
ItemActions,
ItemContent,
ItemDescription,
ItemFooter,
ItemGroup,
ItemHeader,
ItemMedia,
itemMediaVariants,
ItemSeparator,
ItemTitle,
itemVariants
}Update the import paths to match your project setup.
Usage
import {
Item,
ItemActions,
ItemContent,
ItemDescription,
ItemTitle
} from "~/components/ui/item"<Item>
<ItemContent>
<ItemTitle>Title</ItemTitle>
<ItemDescription>Description</ItemDescription>
</ItemContent>
<ItemActions>
<button type="button">Open</button>
</ItemActions>
</Item>Composition
Use the following composition to build an Item:
ItemGroup
โโโ Item
โโโ ItemHeader
โโโ ItemMedia
โโโ ItemContent
โ โโโ ItemTitle
โ โโโ ItemDescription
โโโ ItemActions
โโโ ItemFooterUse ItemSeparator between items in a group when needed.
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.
Variant
Use the variant prop to change the visual style of the item.
Transparent background with no border.
Outlined style with a visible border.
Muted background for secondary content.
// Inline SVG icons from Lucide (https://lucide.dev), ISC License, Copyright (c) Lucide Icons and Contributors.
import {
Item,
ItemContent,
ItemDescription,
ItemMedia,
ItemTitle
} from "~/components/ui/item"
export default function ItemVariant() {
return (
<div class="flex w-full max-w-md flex-col gap-6">
<Item>
<ItemMedia variant="icon">
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
>
<polyline points="22 12 16 12 14 15 10 15 8 12 2 12" />
<path d="M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z" />
</svg>
</ItemMedia>
<ItemContent>
<ItemTitle>Default Variant</ItemTitle>
<ItemDescription>
Transparent background with no border.
</ItemDescription>
</ItemContent>
</Item>
<Item variant="outline">
<ItemMedia variant="icon">
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
>
<polyline points="22 12 16 12 14 15 10 15 8 12 2 12" />
<path d="M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z" />
</svg>
</ItemMedia>
<ItemContent>
<ItemTitle>Outline Variant</ItemTitle>
<ItemDescription>
Outlined style with a visible border.
</ItemDescription>
</ItemContent>
</Item>
<Item variant="muted">
<ItemMedia variant="icon">
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
>
<polyline points="22 12 16 12 14 15 10 15 8 12 2 12" />
<path d="M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z" />
</svg>
</ItemMedia>
<ItemContent>
<ItemTitle>Muted Variant</ItemTitle>
<ItemDescription>
Muted background for secondary content.
</ItemDescription>
</ItemContent>
</Item>
</div>
)
}Size
Use the size prop to change the size of the item. Available sizes are default, sm, and xs.
The standard size for most use cases.
A compact size for dense layouts.
The most compact size available.
// Inline SVG icons from Lucide (https://lucide.dev), ISC License, Copyright (c) Lucide Icons and Contributors.
import {
Item,
ItemContent,
ItemDescription,
ItemMedia,
ItemTitle
} from "~/components/ui/item"
export default function ItemSize() {
return (
<div class="flex w-full max-w-md flex-col gap-6">
<Item variant="outline">
<ItemMedia variant="icon">
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
>
<polyline points="22 12 16 12 14 15 10 15 8 12 2 12" />
<path d="M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z" />
</svg>
</ItemMedia>
<ItemContent>
<ItemTitle>Default Size</ItemTitle>
<ItemDescription>
The standard size for most use cases.
</ItemDescription>
</ItemContent>
</Item>
<Item size="sm" variant="outline">
<ItemMedia variant="icon">
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
>
<polyline points="22 12 16 12 14 15 10 15 8 12 2 12" />
<path d="M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z" />
</svg>
</ItemMedia>
<ItemContent>
<ItemTitle>Small Size</ItemTitle>
<ItemDescription>A compact size for dense layouts.</ItemDescription>
</ItemContent>
</Item>
<Item size="xs" variant="outline">
<ItemMedia variant="icon">
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
>
<polyline points="22 12 16 12 14 15 10 15 8 12 2 12" />
<path d="M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z" />
</svg>
</ItemMedia>
<ItemContent>
<ItemTitle>Extra Small Size</ItemTitle>
<ItemDescription>The most compact size available.</ItemDescription>
</ItemContent>
</Item>
</div>
)
}Icon
Use ItemMedia with variant="icon" to display an icon.
New login detected from unknown device.
// Inline SVG icons from Lucide (https://lucide.dev), ISC License, Copyright (c) Lucide Icons and Contributors.
import { Button } from "~/components/ui/button"
import {
Item,
ItemActions,
ItemContent,
ItemDescription,
ItemMedia,
ItemTitle
} from "~/components/ui/item"
export default function ItemIcon() {
return (
<div class="flex w-full max-w-lg flex-col gap-6">
<Item variant="outline">
<ItemMedia variant="icon">
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
>
<path d="M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z" />
</svg>
</ItemMedia>
<ItemContent>
<ItemTitle>Security Alert</ItemTitle>
<ItemDescription>
New login detected from unknown device.
</ItemDescription>
</ItemContent>
<ItemActions>
<Button size="sm" variant="outline">
Review
</Button>
</ItemActions>
</Item>
</div>
)
}Avatar
You can use ItemMedia with variant="avatar" to display an avatar.

Last seen 5 minutes ago



Invite your team to collaborate on this project.
// Inline SVG icons from Lucide (https://lucide.dev), ISC License, Copyright (c) Lucide Icons and Contributors.
import { Button } from "~/components/ui/button"
import {
Item,
ItemActions,
ItemContent,
ItemDescription,
ItemMedia,
ItemTitle
} from "~/components/ui/item"
export default function ItemAvatar() {
return (
<div class="flex w-full max-w-lg flex-col gap-6">
<Item variant="outline">
<ItemMedia>
<img
alt="@ryansolid"
class="size-10 rounded-full object-cover grayscale"
src="https://github.com/ryansolid.png"
/>
</ItemMedia>
<ItemContent>
<ItemTitle>Ryan Carniato</ItemTitle>
<ItemDescription>Last seen 5 minutes ago</ItemDescription>
</ItemContent>
<ItemActions>
<Button
aria-label="Invite"
class="rounded-full"
size="icon-sm"
variant="outline"
>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
>
<path d="M5 12h14" />
<path d="M12 5v14" />
</svg>
</Button>
</ItemActions>
</Item>
<Item variant="outline">
<ItemMedia>
<div class="flex -space-x-2 [&>img]:ring-2 [&>img]:ring-background [&>img]:grayscale">
<img
alt="@stefan-karger"
class="hidden size-8 rounded-full object-cover sm:block"
src="https://github.com/stefan-karger.png"
/>
<img
alt="@carere"
class="hidden size-8 rounded-full object-cover sm:block"
src="https://github.com/carere.png"
/>
<img
alt="@ryansolid"
class="size-8 rounded-full object-cover"
src="https://github.com/ryansolid.png"
/>
</div>
</ItemMedia>
<ItemContent>
<ItemTitle>No Team Members</ItemTitle>
<ItemDescription>
Invite your team to collaborate on this project.
</ItemDescription>
</ItemContent>
<ItemActions>
<Button size="sm" variant="outline">
Invite
</Button>
</ItemActions>
</Item>
</div>
)
}Image
Use ItemMedia with variant="image" to display an image.
import { For } from "solid-js"
import {
Item,
ItemContent,
ItemDescription,
ItemGroup,
ItemMedia,
ItemTitle
} from "~/components/ui/item"
const tracks = [
{
title: "Midnight City Lights",
artist: "Neon Dreams",
album: "Electric Nights",
duration: "3:45"
},
{
title: "Coffee Shop Conversations",
artist: "The Morning Brew",
album: "Urban Stories",
duration: "4:05"
},
{
title: "Digital Rain",
artist: "Cyber Symphony",
album: "Binary Beats",
duration: "3:30"
}
]
export default function ItemImage() {
return (
<div class="flex w-full max-w-md flex-col gap-6">
<ItemGroup class="gap-4">
<For each={tracks}>
{(track) => (
<Item as="a" href="#" role="listitem" variant="outline">
<ItemMedia variant="image">
<img
alt={track.title}
class="grayscale"
src={`https://avatar.vercel.sh/${track.title}`}
/>
</ItemMedia>
<ItemContent>
<ItemTitle class="line-clamp-1">
{track.title} -{" "}
<span class="text-muted-foreground">{track.album}</span>
</ItemTitle>
<ItemDescription>{track.artist}</ItemDescription>
</ItemContent>
<ItemContent class="flex-none text-center">
<ItemDescription>{track.duration}</ItemDescription>
</ItemContent>
</Item>
)}
</For>
</ItemGroup>
</div>
)
}Group
Use ItemGroup to group related items together.

@stefan_e_k

@carere_dev

@RyanCarniato
// Inline SVG icons from Lucide (https://lucide.dev), ISC License, Copyright (c) Lucide Icons and Contributors.
import { For } from "solid-js"
import { Button } from "~/components/ui/button"
import {
Item,
ItemActions,
ItemContent,
ItemDescription,
ItemGroup,
ItemMedia,
ItemTitle
} from "~/components/ui/item"
const people = [
{
username: "stefan-karger",
avatar: "https://github.com/stefan-karger.png",
twitter: "@stefan_e_k"
},
{
username: "carere",
avatar: "https://github.com/carere.png",
twitter: "@carere_dev"
},
{
username: "ryansolid",
avatar: "https://github.com/ryansolid.png",
twitter: "@RyanCarniato"
}
]
export default function ItemGroupExample() {
return (
<ItemGroup class="max-w-sm">
<For each={people}>
{(person) => (
<Item variant="outline">
<ItemMedia>
<img
alt={`@${person.username}`}
class="size-8 rounded-full object-cover grayscale"
src={person.avatar}
/>
</ItemMedia>
<ItemContent class="gap-1">
<ItemTitle>{person.username}</ItemTitle>
<ItemDescription>{person.twitter}</ItemDescription>
</ItemContent>
<ItemActions>
<Button class="rounded-full" size="icon" variant="ghost">
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
>
<path d="M5 12h14" />
<path d="M12 5v14" />
</svg>
</Button>
</ItemActions>
</Item>
)}
</For>
</ItemGroup>
)
}Header
Use ItemHeader to add a header above the item content.
Everyday tasks and UI generation.
Advanced thinking or reasoning.
Open source model for everyone.
import { For } from "solid-js"
import {
Item,
ItemContent,
ItemDescription,
ItemGroup,
ItemHeader,
ItemTitle
} from "~/components/ui/item"
const models = [
{
name: "v0-1.5-sm",
description: "Everyday tasks and UI generation.",
image:
"https://images.unsplash.com/photo-1650804068570-7fb2e3dbf888?q=80&w=640&auto=format&fit=crop"
},
{
name: "v0-1.5-lg",
description: "Advanced thinking or reasoning.",
image:
"https://images.unsplash.com/photo-1610280777472-54133d004c8c?q=80&w=640&auto=format&fit=crop"
},
{
name: "v0-2.0-mini",
description: "Open source model for everyone.",
image:
"https://images.unsplash.com/photo-1602146057681-08560aee8cde?q=80&w=640&auto=format&fit=crop"
}
]
export default function ItemHeaderDemo() {
return (
<div class="flex w-full max-w-xl flex-col gap-6">
<ItemGroup class="grid grid-cols-3 gap-4">
<For each={models}>
{(model) => (
<Item variant="outline">
<ItemHeader>
<img
alt={model.name}
class="aspect-square w-full rounded-sm object-cover"
src={model.image}
/>
</ItemHeader>
<ItemContent>
<ItemTitle>{model.name}</ItemTitle>
<ItemDescription>{model.description}</ItemDescription>
</ItemContent>
</Item>
)}
</For>
</ItemGroup>
</div>
)
}Link
Use the as prop to render Item as a link. The anchor receives the hover and focus styles.
// Inline SVG icons from Lucide (https://lucide.dev), ISC License, Copyright (c) Lucide Icons and Contributors.
import {
Item,
ItemActions,
ItemContent,
ItemDescription,
ItemTitle
} from "~/components/ui/item"
export default function ItemLink() {
return (
<div class="flex w-full max-w-md flex-col gap-4">
<Item as="a" href="#">
<ItemContent>
<ItemTitle>Visit our documentation</ItemTitle>
<ItemDescription>
Learn how to get started with our components.
</ItemDescription>
</ItemContent>
<ItemActions>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
>
<path d="m9 18 6-6-6-6" />
</svg>
</ItemActions>
</Item>
<Item
as="a"
href="#"
rel="noopener noreferrer"
target="_blank"
variant="outline"
>
<ItemContent>
<ItemTitle>External resource</ItemTitle>
<ItemDescription>
Opens in a new tab with security attributes.
</ItemDescription>
</ItemContent>
<ItemActions>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
>
<path d="M7 7h10v10" />
<path d="M7 17 17 7" />
</svg>
</ItemActions>
</Item>
</div>
)
}<Item as="a" href="/dashboard">
<ItemMedia variant="icon">
<HomeIcon />
</ItemMedia>
<ItemContent>
<ItemTitle>Dashboard</ItemTitle>
<ItemDescription>Overview of your account and activity.</ItemDescription>
</ItemContent>
</Item>Dropdown
// Inline SVG icons from Lucide (https://lucide.dev), ISC License, Copyright (c) Lucide Icons and Contributors.
import { For } from "solid-js"
import { Avatar, AvatarFallback, AvatarImage } from "~/components/ui/avatar"
import { Button } from "~/components/ui/button"
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuGroup,
DropdownMenuItem,
DropdownMenuTrigger
} from "~/components/ui/dropdown-menu"
import {
Item,
ItemContent,
ItemDescription,
ItemMedia,
ItemTitle
} from "~/components/ui/item"
const people = [
{
username: "stefan-karger",
avatar: "https://github.com/stefan-karger.png",
twitter: "@stefan_e_k"
},
{
username: "carere",
avatar: "https://github.com/carere.png",
twitter: "@carere_dev"
},
{
username: "ryansolid",
avatar: "https://github.com/ryansolid.png",
twitter: "@RyanCarniato"
}
]
export default function ItemDropdown() {
return (
<DropdownMenu>
<DropdownMenuTrigger
render={(partProps) => <Button {...partProps} variant="outline" />}
class="w-fit"
>
Select
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
>
<path d="m6 9 6 6 6-6" />
</svg>
</DropdownMenuTrigger>
<DropdownMenuContent side="bottom" align="end" class="w-56">
<DropdownMenuGroup>
<For each={people}>
{(person) => (
<DropdownMenuItem class="p-0">
<Item class="w-full p-2" size="xs">
<ItemMedia>
<Avatar class="size-6.5">
<AvatarImage src={person.avatar} class="grayscale" />
<AvatarFallback>
{person.username.charAt(0)}
</AvatarFallback>
</Avatar>
</ItemMedia>
<ItemContent class="gap-0">
<ItemTitle>{person.username}</ItemTitle>
<ItemDescription class="leading-none">
{person.twitter}
</ItemDescription>
</ItemContent>
</Item>
</DropdownMenuItem>
)}
</For>
</DropdownMenuGroup>
</DropdownMenuContent>
</DropdownMenu>
)
}API Reference
Item
Main row container for media, text content, and actions.
ItemGroup
A container that groups related items together with consistent styling.
<ItemGroup>
<Item />
<Item />
</ItemGroup>ItemSeparator
A separator between items in a group.
<ItemGroup>
<Item />
<ItemSeparator />
<Item />
</ItemGroup>ItemMedia
Use ItemMedia to display media content such as icons, images, or avatars.
<ItemMedia variant="icon">
<Icon />
</ItemMedia><ItemMedia variant="image">
<img src="..." alt="..." />
</ItemMedia>ItemContent
Wraps the title and description of the item.
<ItemContent>
<ItemTitle>Title</ItemTitle>
<ItemDescription>Description</ItemDescription>
</ItemContent>ItemTitle
Displays the title of the item.
<ItemTitle>Item Title</ItemTitle>ItemDescription
Displays the description of the item.
<ItemDescription>Item description</ItemDescription>ItemActions
Container for action buttons or other interactive elements.
<ItemActions>
<Button>Action</Button>
</ItemActions>ItemHeader
Displays a header above the item content.
<Item>
<ItemHeader>Header</ItemHeader>
<ItemContent>...</ItemContent>
</Item>ItemFooter
Displays a footer below the item content.
<Item>
<ItemContent>...</ItemContent>
<ItemFooter>Footer</ItemFooter>
</Item>