ListItem (Mobile)
One row in a list, with a title, a subtitle and an optional decoration. Use for a tappable list of items.
Health
Source
Accessibility
partially-compliant
Platform
Mobile
📱 Mobile-only
This component is only for mobile. To see how it looks like you can check the mobile storybook with:
yarn workspace alan-mobile dev:install-client -p ios
yarn workspace alan-mobile dev:storybook
Accessibility issues
This component supports accessibility labels via the `accessibilityLabel` prop.
- Overview
- Props
info
Mobile components cannot be previewed in the browser. Use Storybook mobile or run the app locally to test.
Usage
import { ListItem } from "murray/mobile";
<ListItem
title="Title"
subtitle="Sub-title"
decorProps={{
type: "emoji",
visual: "🙈️",
size: "size40",
}}
onPress={() => {}}
/>;
Platform Differences
The mobile ListItem has some differences from the web version:
- Uses
onPressinstead ofonClickfor interaction handlers - Supports
sizeprop ("sm"|"md") for different sizing - Has a
subtitleViewprop for custom subtitle rendering - Supports
accessibilityLabelprop for accessibility - Includes a
negativevariant not available on web
ListItem props
| Name | Type | Default Value | Description | Usage count |
|---|---|---|---|---|
| decorProps | DecorPropsundefined | |||
| error | ReactNode | |||
| hideCaret | booleanundefined | When `onPress` is filled, caret is shown by default. You can disable it with this prop. | ||
| onPress | 2 possibilities((event: GestureResponderEvent) => void)undefined | |||
| optionProps | ListItemOptionPropsundefined | |||
| reserveCaretSpace | booleanundefined | Reserve the caret's horizontal space even when no caret is shown, so options (e.g. amounts) stay right-aligned across rows in a list mixing pressable and non-pressable items. Set it on every row of the list. | ||
| size | "sm""md"undefined | md | ||
| style | 5 possibilitiesundefinedViewStyleViewStyle & falseViewStyle & ""ViewStyle & RecursiveArray<Falsy | ViewStyle> | |||
| subtitle | ReactNode | |||
| subtitleView | ReactNode | |||
| title | ReactNode | |||
| titleColor | 4 possibilitiesundefined`$${string}`Variable<any>OpaqueColorValue | Override the variant's default title color. | ||
| variant | ListItemVariantundefined | default |
Undocumented props
| Name | Type | Default Value | Description | Usage count |
|---|---|---|---|---|
| accessibilityLabel | any | |||
| accessibilityRole | any | |||
| testID | any |