suiss/ui · Component
Item
A flexible row that pairs media, a title, a description and actions, for lists and settings.
Item is an open-source component from suiss/ui for React, React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.
Item is a row container. Inside it, ItemMedia holds an icon, image or avatar, ItemContent stacks an ItemTitle and ItemDescription, and ItemActions holds buttons or indicators at the end. ItemHeader and ItemFooter span the full width of the item, above and below the main row. The whole item can also render as a link or button.
ItemGroup stacks items as a list, and ItemSeparator divides them. Use items to display content; for form controls with labels and validation, use Field.
Installation
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
- Install the following dependencies and add the
cnhelper:
- Copy and paste the following code into your project.
- Update the import paths to match your project setup.
Usage
Composition
Use the following composition to build a Item:
Examples
Variants
Use the variant prop for the item's border and background: default has neither, outline adds a border and muted adds a subtle background.
Sizes
Use the size prop to set the padding and gap: default is the roomiest, then sm, then xs. A group of sm or xs items is spaced more tightly.
As link
Use the render prop to render the whole item as a link or button, so the row is one focusable target. A linked item gets the accent background on hover.
Set asChild and pass a link or button as the child to render the whole item as it, so the row is one focusable target. A linked item gets the accent background on hover.
Pass a render function that returns a link or button and spread the props it receives onto it, so the row is one focusable target. A linked item gets the accent background on hover.
With image
Set variant="image" on ItemMedia to crop an image into a rounded square that scales with the item size. This list of people adds separators and an invite button on each row.
Inset
Set variant="inset" on ItemGroup to group the items into a rounded list on bg-muted, with square item corners and separators inset from the start.
With avatar
An item with an Avatar as media and a Message button.
With header and footer
A plan summary with a price in the header and a renewal date and action in the footer.
Accessibility
ItemGrouphas thelistrole; give eachItemin it thelistitemrole.ItemSeparatorhas thenonerole, so it is ignored by assistive technology.- An item rendered as a link or button is a single focusable element and shows a focus ring.
- Give icon-only action buttons an accessible name with
aria-label.
API Reference
ItemGroup
Stacks items as a list, or groups them into an inset list.
| Prop | Type | Default |
|---|---|---|
variant | "default" | "inset" | "default" |
Also accepts the props of React.ComponentProps<"div">.
The group has the list role, so set role="listitem" on each Item inside it.
ItemSeparator
A divider between items.
Also accepts the props of React.ComponentProps<"div">.
Item
The row container for media, content and actions.
| Prop | Type | Default |
|---|---|---|
variant | "default" | "outline" | "muted" | "default" |
size | "default" | "sm" | "xs" | "default" |
Also accepts the props of useRender.ComponentProps<"div">.
| Prop | Type | Default |
|---|---|---|
asChild | boolean | false |
Also accepts the props of React.ComponentProps<"div">.
| Prop | Type | Default |
|---|---|---|
render | (props) => React.ReactNode | - |
Also accepts the props of React.ComponentProps<"div">.
Item sets data-variant and data-size for styling.
ItemMedia
Holds an icon, image or avatar at the start of the item.
| Prop | Type | Default |
|---|---|---|
variant | "default" | "icon" | "image" | "default" |
Also accepts the props of React.ComponentProps<"div">.
icon sizes an icon, image crops an image into a rounded square, and default renders the media as is. When ItemDescription is present, the media aligns to the top of the item instead of its center.
ItemContent
Stacks the title and description.
Also accepts the props of React.ComponentProps<"div">.
ItemTitle
The item's title, limited to one line.
Also accepts the props of React.ComponentProps<"div">.
ItemDescription
Supporting text, limited to two lines.
Also accepts the props of React.ComponentProps<"p">.
ItemActions
Holds buttons or indicators at the end of the item.
Also accepts the props of React.ComponentProps<"div">.
ItemHeader
A full-width row above the item's content.
Also accepts the props of React.ComponentProps<"div">.
ItemFooter
A full-width row below the item's content.
Also accepts the props of React.ComponentProps<"div">.
Each part sets a data-slot, such as item-media or item-title, for styling.
Web preview
Item is a row that renders as a Pressable with the button role when it has onPress or onLongPress, and as a plain View with the listitem role otherwise. It has three variants (default, outline, muted) and three sizes (default, sm, xs).
Compose a row from ItemMedia, ItemContent (holding ItemTitle and ItemDescription) and ItemActions. Use ItemHeader and ItemFooter for full-width rows above or below the main content.
ItemGroup stacks items as a list. Its inset variant joins them into one rounded card with square inner corners, which suits settings screens; add ItemSeparator between rows to draw an inset divider.
Installation
- Install the following dependencies:
- Copy and paste the following code into
components/ui/item.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
- Copy and paste the following code into
components/ui/item.tsx:
- Update the import paths to match your project setup.
- Copy and paste the following code into
components/ui/item.tsx:
- Update the import paths to match your project setup.
-
Target iOS 17 or later.
-
Add the Swift package to your app:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Add the files to your app target.
- Apply the Compose compiler plugin, enable Compose, set
compileSdkto 37 or higher andminSdkto 24 or higher, and add the dependencies:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Update the
com.esuiss.uipackage names to match your project.
Usage
This code uses Tailwind classes that need Uniwind or NativeWind. With StyleSheet, pass the same values through the style props.
Examples
Inset group
Pressable rows in an inset group, with colored icon tiles, separators and trailing chevrons.

Accessibility
ItemGrouphas thelistrole.- A static
Itemhas thelistitemrole; an item withonPressoronLongPresshas thebuttonrole and fades to 80% opacity while pressed. disableddims the item and blocks presses.ItemSeparatoris hidden from VoiceOver and TalkBack.
API Reference
ItemGroup
List container for items.
| Prop | Type | Default |
|---|---|---|
variant | "default" | "inset" | "default" |
Also accepts the props of ViewProps.
default stacks items with a gap; inset joins them into one rounded card.
ItemSeparator
Divider between items, inset inside an inset group.
Also accepts the props of ViewProps.
Item
The row itself, pressable when given a press handler.
| Prop | Type | Default |
|---|---|---|
variant | "default" | "outline" | "muted" | "default" |
size | "default" | "sm" | "xs" | "default" |
render | RenderProp | - |
Also accepts the props of PressableProps.
size sets the padding and gap. Pass render to render the row as another component, such as a Pressable, while keeping the item styles.
ItemMedia
Leading icon, image or avatar.
| Prop | Type | Default |
|---|---|---|
variant | "default" | "icon" | "image" | "default" |
Also accepts the props of ViewProps.
icon sizes icons to 16 points, and image makes a square thumbnail that shrinks with the item size.
ItemContent
Flexible column for the title and description.
Also accepts the props of ViewProps.
ItemTitle
Single-line title.
Also accepts the props of React.ComponentProps<typeof Text>.
ItemTitle truncates to one line and ItemDescription to two by default; override with numberOfLines.
ItemDescription
Secondary text, up to two lines.
Also accepts the props of React.ComponentProps<typeof Text>.
ItemActions
Trailing row for values, buttons or chevrons.
Also accepts the props of ViewProps.
Text inside it picks up text-muted-foreground.
ItemHeader
Full-width row above the content.
Also accepts the props of ViewProps.
ItemFooter
Full-width row below the content.
Also accepts the props of ViewProps.
ItemVariant
Values: .default, .outline, .muted.
ItemSize
Values: .default, .sm, .xs.
ItemGroupVariant
Values: .default, .inset.
ItemGroup
List container for items.
| Parameter | Type | Default |
|---|---|---|
_ variant | ItemGroupVariant: .default | .inset | .default |
content | () -> Content | - |
ItemSeparator
Divider between items, inset inside an inset group.
Takes no parameters.
Item
The row itself, pressable when given a press handler.
| Parameter | Type | Default |
|---|---|---|
_ variant | ItemVariant: .default | .outline | .muted | .default |
size | ItemSize: .default | .sm | .xs | .default |
action | (() -> Void)? | nil |
content | () -> Content | - |
ItemMediaVariant
Values: .default, .icon, .image.
ItemMedia
Leading icon, image or avatar.
| Parameter | Type | Default |
|---|---|---|
_ variant | ItemMediaVariant: .default | .icon | .image | .default |
content | () -> Content | - |
ItemContent
Flexible column for the title and description.
| Parameter | Type | Default |
|---|---|---|
content | () -> Content | - |
ItemTitle
Single-line title.
| Parameter | Type | Default |
|---|---|---|
content | () -> Content | - |
_ title | LocalizedStringKey | - |
verbatim | String | - |
Overloads: init(content:), init(_:), init(verbatim:).
ItemDescription
Secondary text, up to two lines.
| Parameter | Type | Default |
|---|---|---|
_ description | LocalizedStringKey | - |
verbatim | String | - |
Overloads: init(_:), init(verbatim:).
ItemActions
Trailing row for values, buttons or chevrons.
| Parameter | Type | Default |
|---|---|---|
content | () -> Content | - |
ItemHeader
Full-width row above the content.
| Parameter | Type | Default |
|---|---|---|
content | () -> Content | - |
ItemFooter
Full-width row below the content.
| Parameter | Type | Default |
|---|---|---|
content | () -> Content | - |
ItemVariant
Values: Default, Outline, Muted.
ItemSize
Values: Default, Sm, Xs.
ItemGroupVariant
Values: Default, Inset.
ItemMediaVariant
Values: Default, Icon, Image.
ItemGroup
List container for items.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
variant | ItemGroupVariant: Default | Inset | ItemGroupVariant.Default |
content | @Composable ColumnScope.() -> Unit | - |
ItemSeparator
Divider between items, inset inside an inset group.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
Item
The row itself, pressable when given a press handler.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
variant | ItemVariant: Default | Outline | Muted | ItemVariant.Default |
size | ItemSize: Default | Sm | Xs | ItemSize.Default |
onClick | (() -> Unit)? | null |
onLongClick | (() -> Unit)? | null |
enabled | Boolean | true |
selected | Boolean? | null |
role | Role? | Role.Button |
onClickLabel | String? | null |
content | @Composable () -> Unit | - |
ItemMedia
Leading icon, image or avatar.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
variant | ItemMediaVariant: Default | Icon | Image | ItemMediaVariant.Default |
content | @Composable BoxScope.() -> Unit | - |
ItemContent
Flexible column for the title and description.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
content | @Composable ColumnScope.() -> Unit | - |
ItemTitle
Single-line title.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
content | @Composable RowScope.() -> Unit | - |
text | String | - |
Overloads: ItemTitle(content), ItemTitle(text).
ItemDescription
Secondary text, up to two lines.
| Parameter | Type | Default |
|---|---|---|
text | String | - |
modifier | Modifier | Modifier |
ItemActions
Trailing row for values, buttons or chevrons.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
content | @Composable RowScope.() -> Unit | - |
ItemHeader
Full-width row above the content.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
content | @Composable RowScope.() -> Unit | - |
ItemFooter
Full-width row below the content.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
content | @Composable RowScope.() -> Unit | - |
