List Item
One row of a list: something at the left, a title with a description, and a value or control at the right. A row can be static, one button or one link.
Playground
Installation
List Item comes with WunderUI Core and Pro, in the package from your plan. See the plans.
Then import what you need:
import {
ListItem,
CoinLogo,
CoinMark,
IntegrationLogo,
IntegrationMark,
ListFlag,
ListItemData,
ListItemLeading,
ListItemLeadingProps,
ListItemProps,
ListItems,
ListItemsProps,
ListItemTrailing,
ListItemTrailingProps,
} from "@wunderui/react"Then use it:
import { ListItems } from "@wunderui/react"
export function Payments() {
return (
<ListItems
aria-label="Payments"
items={[
{ id: "nora", title: "Nora Lindgren", description: "WunderUI Pro, one-time", trailing: { type: "value", value: "$299.00", sub: "Today" } },
{ id: "daniel", title: "Daniel Okafor", description: "WunderUI Core, one-time", trailing: { type: "value", value: "$199.00", sub: "Yesterday" } },
]}
/>
)
}Expected result: You see two rows divided by a line, each with a name over its plan and the amount with the day at the right.
When to use
Use List Item for
- One row of a list in a card, a List Group or a List Panel
- Rows that people press to open, select or follow
- Rows with a figure, a status or one control at the right
Use something else for
- List View for a short framed list whose rows carry their own controls and need no row states
- Item Card for one object that stands on its own, with its own border
- Data Table for many rows that people sort, filter or compare by column
Leading
The leading slot takes one of eleven types: identities like avatar, icon tile or logo, and markers like checkbox, rank or date. Any React node works too.
Leading
Leading
Trailing
The trailing slot takes one of thirteen types, figures to read and controls to use. A control keeps its own click and keyboard behaviour inside a button or link row.
Trailing
Trailing
Row type
A row with a select handler is one button across the whole row, and a row with an href is one link. Without either it is static text.
Row
States
Selected, disabled and destructive are set by you. Hover and pressed are automatic: an interactive row shows a light fill on hover and a small press on click.
Density
Comfortable rows have 12 px of vertical padding, compact rows 8 px. Set it once on the list.
Long text
A cut title ends in an ellipsis and shows its full text as a tooltip. A description wraps onto more lines.
Text
Keyboard interactions
A row with a select handler or href is one native button or link. Controls in the leading and trailing slots are separate tab stops, in the order they are written.
- TaborShiftTab
- Moves focus to the next or previous control: a leading checkbox, then the row button or link, then the trailing control, then the next row. A disabled row and a static row are skipped.
- EnterorSpace
- Presses the focused row button and calls . On a toggle row this changes .
- Enter
- Follows the focused row link.
- Space
- Toggles a focused leading Checkbox or trailing Switch.
- EnterorSpaceorArrowDown
- Opens the menu of a trailing icon button that has a . Inside the menu the arrow keys move, Enter picks and Escape closes it.
A static row takes no focus. Arrow keys don't move between rows because the list is not a listbox; use List Group Master-Detail or Actions for arrow-key navigation.
Behavior and motion
What the row does with state, content, the DOM and motion.
- One button over the whole row
- With a select handler the title is a button stretched over the whole row; with an href it is a link. Leading and trailing controls sit above it and take their own clicks.
- States
- An interactive row fills with the page background on hover and scales to 98 % when pressed. A selected row keeps the subtle fill, and a disabled row dims to 40 %.
- Focus
- Keyboard focus draws a 2 px indigo outline around the whole row. The divider next to a focused, hovered or selected row fades out so the highlight is never cut by a line.
- Long text
- The title is cut to one line, and while it is cut, hovering it shows the full text as a native tooltip. The description and meta line wrap.
- Names for assistive technology
- The title names the row's controls: checkboxes, switches and progress bars are labelled by it, and a trailing button reads as its label plus the title. Avatars list their people for screen readers.
- Dividers and density
- Dividers sit inside the row's reserved space, so showing or hiding one never moves the layout. Without dividers rows sit 4 px apart; density comes from ListItems and a row can override it.
- Motion and reduced motion
- The row fills and presses quickly and the divider fades. With reduced motion the press scale is off and only colour and opacity changes remain, so hover and selected fills still show.
Anatomy
The parts of a row, numbered in the figure. The divider is a 1 px line drawn under the row, not a part of its own.
- Nora LindgrenWunderUI Pro, one-time$299.00Today
- Daniel OkaforWunderUI Core, one-time$199.00Yesterday
- data-slot="list-items"
The list: a ul with the list role that holds the rows and tells them the density and whether they have dividers. It has no surface of its own, so put it in a card, a panel or a List Group.
- data-slot="list-item"
One row: a li with a rounded inner row, 12 px side padding and 12 px between parts. Vertical padding is 12 px comfortable or 8 px compact, and a 1 px divider sits under the row, none on the last.
The leading slot at the left. A spec object draws one of eleven types (avatar, icon tile, logo, flag, coin, checkbox, icon, rank, date, step, drag handle), or place any React node.
The title in 14 px medium, cut to one line with an ellipsis. It is a button with a select handler, a link with an href, otherwise plain text.
The description under the title in 12 px secondary text, wrapping onto more lines. A meta line adds a third line in tertiary text.
The trailing slot at the right. A spec object draws one of thirteen types (value, trend, progress, button, switch, menu and more), or place any node; it keeps its width and the text gives way first.
- data-slot="coin-logo"
- data-slot="coin-mark"
- data-slot="integration-logo"
- data-slot="integration-mark"
- data-slot="list-flag"
- data-slot="list-item-leading"
- data-slot="list-item-trailing"
Best practices
- Do
Give a row people can press a select handler or an href. The title then becomes one button or link over the whole row, so pointer and keyboard reach it the same way.
- Do
Keep one idea per slot: an avatar or icon at the left, a figure or one control at the right. Put the rest in the description.
- Do
Use href when pressing the row goes to another page and a select handler when it changes something on this one. Assistive technology treats a link and a button differently.
- Do
Write a title that is understandable on its own, because trailing controls are named after it: a button labelled Resend reads as Resend Maya Kessler.
- Don’t
Don't put a button in the trailing slot and also give the row a select handler unless they do different things. Two controls for one action make the row hard to read.
- Don’t
Don't use the state prop in product code. It freezes a look for documentation; live rows get their state from the pointer, selected and disabled.
- Don’t
Don't set a row's padding or radius by hand. A card with other geometry sets row padding and radius variables, so the rows stay concentric to it.
API reference
A List Item takes the props below and every attribute of a li, and ListItems takes those of a ul. The same row data is what the items array of ListItems, List Group and List Panel holds, plus an id.
The list: a ul with the list role that holds the rows and tells them the density and whether they have dividers. It has no surface of its own, so put it in a card, a panel or a List Group.
One row: a li with a rounded inner row, 12 px side padding and 12 px between parts. Vertical padding is 12 px comfortable or 8 px compact, and a 1 px divider sits under the row, none on the last.
Notes for AI
Give your coding assistant the Markdown reference instead of screenshots.
get_component("list-item")The full library index for assistants is at /llms.txt.