List item
Rows for lists & settings. 4 types.
Orders
Express deliveryDhaka, within 3 hours
Nusrat JahanOrdered 3 times
Low-stock alertsEmail when under 10
import * as React from "react";
import { Inbox, Zap } from "@/components/ui/icons";
import { ListItem } from "@/components/ui/list-item";
export default function Example() {
const [on, setOn] = React.useState(true);
return (
<div style={{ width: 380, display: "grid", gap: 4 }}>
<ListItem type="one-line" leading={<Inbox />} title="Orders" />
<ListItem type="two-line" leading={<Zap />} title="Express delivery" subtitle="Dhaka, within 3 hours" />
<ListItem type="avatar" initials="NJ" title="Nusrat Jahan" subtitle="Ordered 3 times" />
<ListItem type="toggle" title="Low-stock alerts" subtitle="Email when under 10" checked={on} onCheckedChange={setOn} />
</div>
);
}
Installation
$ npx uix-ui@latest add list-itemThis copies the file into components/ui/list-item.tsx in your project. npx shadcn@latest add @uix/list-item works too.
Usage
import { ListItem } from "@/components/ui/list-item";
<div style={{ width: 380, display: "grid", gap: 4 }}>
<ListItem type="one-line" leading={<Inbox />} title="Orders" />
<ListItem type="two-line" leading={<Zap />} title="Express delivery" subtitle="Dhaka, within 3 hours" />
<ListItem type="avatar" initials="NJ" title="Nusrat Jahan" subtitle="Ordered 3 times" />
<ListItem type="toggle" title="Low-stock alerts" subtitle="Email when under 10" checked={on} onCheckedChange={setOn} />
</div>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
type | one-line | two-line | avatar | toggle | "one-line" | |
title | React.ReactNode | – | |
subtitle | React.ReactNode | – | Second line; used by every type except "one-line". |
leading | React.ReactNode | – | Icon or image in the leading box. |
initials | string | – | Initials for the "avatar" type. |
trailing | React.ReactNode | – | Replaces the trailing chevron. |
checked | boolean | false | State of the switch in the "toggle" type. |
onCheckedChange | (checked: boolean) => void | – | |
leadingCheckbox | React.ReactNode | – | Checkbox before the content (for example <Checkbox aria-label="Select" />). |
trailingBadge | React.ReactNode | – | Badge before the chevron or switch (for example a count). |
Everything else is passed to the root element, so className, aria-* and event handlers work as usual.
Dependencies
Installed for you by the CLI.
class-variance-authorityclsxtailwind-merge
lib/utils.tscomponents/ui/icons.tsx