# Line Item

One product line in a cart or order summary, with image, variant, quantity and price.

- Category: Commerce
- Page: https://wunderui.com/components/line-item
- Tier: Core and Pro

## Install

Line Item ships with WunderUI Core and Pro in the @wunderui/react package.

## Import

```tsx
import { LineItem, LineItemProps } from "@wunderui/react"
```

## Minimal usage

Then use it:

```tsx
import { LineItem } from "@wunderui/react"

export function Line() {
  return <LineItem name="Nord standing desk" variant="Oak, 160 × 80 cm" price="$649.00" tint="indigo" />
}
```

Expected result: You see a row with a 48 px indigo tile and a package icon on the left, the product name with the variant under it, and the price on the right. Put it in a bordered card to see its padding.

## When to use

### Use Line Item for

- The lines of a cart, with a quantity stepper or a remove button before the price
- The compact products of an order summary or an invoice
- A receipt or an order confirmation where each product is one row

### Use something else

- [Product Card](https://wunderui.com/components/product-card) for a product to browse, with a large image, a rating and an add to cart button
- [Compact Product Card](https://wunderui.com/components/product-card) for a small suggestion beside the cart with a quick add button
- [Table](https://wunderui.com/components/table) for an order with many columns, such as SKU, unit price, quantity and total

## Behavior

How the row treats its content, width and slot. It is display only, so it has no hover, focus or keyboard behaviour of its own.

- **A row, not a control:** Line Item renders one div with no role and nothing to focus. Controls you put in the trailing slot keep their own focus ring and keyboard behaviour, and nothing in the row reacts to hover.
- **Quantity:** A quantity adds × n after the name, only above one. It stays visible when a long name is cut; skip it when a stepper in the trailing slot already shows the quantity.
- **Long text:** The name and variant are each one line and end in an ellipsis when the row is too narrow. The price and trailing slot never shrink, so keep the trailing content small.
- **Image:** With an image the thumbnail is the photo, cropped to a square. Without one, the tile takes a tint (yellow by default) and a package icon; a broken address leaves an empty tile.
- **Size:** Regular pads the row and uses a 48 px thumbnail. Compact has no padding and a 40 px thumbnail, so use it inside a panel that has padding already; a class can override either.
- **Updates:** The row has no live region. When a stepper changes the quantity and the price, announce the new total yourself, for example with a polite live subtotal as the cart example does.
- **Motion and reduced motion:** Nothing in the row is animated, so there is nothing to reduce. The controls you put in the trailing slot bring their own transitions.

## Anatomy

- `LineItem`: A div that lays the parts out in one row, 12 px apart. A regular row has 16 px side and 12 px vertical padding, a compact row none; it has no role, border or background of its own.
- `Product image`: The thumbnail, 48 px square (40 px compact) with 8 px corners. It shows the image, or a tinted tile with a package icon when there is none, and the photo has an empty alt.
- `Name`: The product name in 12 px medium text. It is cut with an ellipsis when the row is too narrow.
- `Quantity`: × n after the name in the tertiary text colour. It is drawn only above one and is never cut.
- `Variant`: A second line under the name in 11 px tertiary text, for the colour, size or plan. It is cut with an ellipsis.
- `Trailing`: A slot between the text and the price for your own controls, such as a quantity stepper or a remove button.
- `Price`: The price of the line in 12 px semibold text. It can hold a discounted price, and it is never cut or wrapped.

## Best practices

### When to use

- Use Line Item for the lines of a cart, a checkout summary, an order confirmation or an invoice. Use Product Card for a product to browse and the compact Product Card for a suggestion beside a cart.

### Do

- Pass the price already formatted with the currency, like $649.00. The row formats no numbers, and the total of a line (unit price times quantity) is yours to calculate.
- Use the compact size inside a panel that brings its own padding, such as an order summary. Use regular, the default, for a list directly in a card with dividers between rows.
- Put the lines in a list so a screen reader announces how many products there are. The row itself is a div with no role.
- Give every control in the trailing slot a name that includes the product, like Remove Nord standing desk. Several buttons named Remove can't be told apart.
- Show a discounted price with the old price struck through and screen-reader text for both (Was, Now). Colour and a line-through alone don't say which one is current.

### Don't

- Don't pass a quantity of 1 and expect × 1. The quantity is drawn only above one; when a stepper in the trailing slot shows it, leave quantity out so it isn't written twice.
- Don't put a long sentence in the variant. It is one line and is cut with an ellipsis, so keep it to the choices the buyer made.
- Don't expect the row to be a link. It has no click handler or focus; to open the product, put a link in the name or wrap the row in your own.

## API reference

### LineItem

| Prop | Type | Default | Description |
|---|---|---|---|
| name* | React.ReactNode |  | The product name. It is cut with an ellipsis on one line when the row is too narrow. It can be a node, for example a link. |
| price* | React.ReactNode |  | The price of the line, already formatted. It is a node, so it can hold a discounted price. It stays on one line and never shrinks. |
| className | string |  | Added to the row. Use it for the width, the padding or a divider. |
| image | string |  | The address of the product photo. Without it the thumbnail is a tinted tile with an icon. |
| quantity | number |  | The number of items. It adds `× n` after the name when it is above one, and nothing when it is one or not set. |
| size | "compact" \| "regular" | "regular" | `regular` (default) is a 48 px thumbnail in a row with padding. `compact` is a 40 px thumbnail with no padding, for use inside a panel that has its own. |
| tint | "indigo" \| "blue" \| "purple" \| "pink" \| "red" \| "orange" \| "yellow" \| "green" \| "alternative" | "yellow" | The tint of the placeholder tile: indigo, blue, purple, pink, red, orange, yellow, green or alternative. Yellow by default. Not used with `image`. |
| trailing | React.ReactNode |  | Content between the text and the price, such as a quantity stepper or a remove button. It does not shrink. |
| variant | React.ReactNode |  | The second line under the name, for the colour, the size or the plan. It is cut with an ellipsis. Omit it for a row with one line of text. |

## Examples

### Content: name, variant, quantity and a long name

### Size: regular and compact

### Image: tinted placeholder or photo

### Trailing: nothing, a quantity stepper or a remove button

### Price: plain, discounted or free

## In context

### Cart: change the quantity or remove a line

Each line puts a stepper before the price and shows its line total; at a quantity of one, minus becomes remove. The subtotal is announced politely, and an empty cart says so.

### Order summary: compact lines in a panel

The panel brings the padding, so the lines are compact. A screen reader announces how many products the order holds and which amount is which.

## For AI agents

`get_component("line-item")`

Hand your agent this page as Markdown or the WunderUI MCP server, not a screenshot.
