List
A bulleted or numbered list. Unordered by default; `type` and `listStyleType` change the markers.
compliant
- Overview
- Props
Usage
- Item 1
- Item 2
- Item 3
Ordered lists
Lists are unordered by default, but it can be controlled through the type prop:
- Item 1
- Item 2
List style
You can change the style of the list marker via the listStyleType prop:
- First order item
- First order item with nested list
- First order item
- First order item with nested list
- First order item
- First order item with nested list
Inline lists
Inline list cannot be ordered.
- Item 1
- Item 2
If you can to provide a visual separator, please see the accessibility section below.
Nested lists
Set indent prop to offset nested lists:
- First order item
- First order item with nested list
- Nested item
- Nested item with list
- Even more nested
Mobile nesting workaround
On mobile, it's not possible to nest list. Instead, use different lists and set indent prop to offset nested lists:
<>
<List>
<List.Item>First order item</List.Item>
<List.Item>First order item with nested list</List.Item>
</List>
<List indent={1}>
<List.Item>Nested item</List.Item>
<List.Item>Nested item with list</List.Item>
</List>
<List indent={2}>
<List.Item>Even more nested</List.Item>
</List>
</>
Styling
Text can be styled by relying on the size and color props:
- Item 1
- Item 2
Accessibility
This component handles HTML semantics for the web. If you need to provide a decorative item, typically, a visual separator for inline lists, do not forget to use the aria attribute aria-hidden="true" to hide it from screen readers:
- Item 1
- Item 2
Playground
murray and murray/mobile.List props
| Name | Type | Default Value | Description | Usage count |
|---|---|---|---|---|
| children* | ReactNode | `List.Item` components only | ||
| color | 4 possibilitiesundefined`$${string}`Variable<any>OpaqueColorValue | |||
| dir | "auto"Directionundefined | |||
| gap | 79 possibilitiesundefinednumber"unset""$0""$1""$2""$4""$6""$8""$10""$12""$14""$16""$20""$24""$28""$32""$36""$40""$44""$48""$56""$64""$80""$96""$112""$128""$144""$160""$176""$192""$px0""$px1""$px2""$px4""$px6""$px8""$px10""$px12""$px14""$px16""$px20""$px24""$px28""$px32""$px36""$px40""$px44""$px48""$px56""$px64""$px80""$px96""$px112""$px128""$px144""$px160""$px176""$px192"Variable<any>UnionableNumber"inherit"`var(${string})`"auto"PercentString`${number}vw``${number}dvw``${number}lvw``${number}svw``${number}vh``${number}dvh``${number}lvh``${number}svh``calc(${string})``min(${string})``max(${string})`"max-content""min-content"MediaProps<number | SpaceTokens> | Gap between items | ||
| indent | numbertrueundefined | 0 | Offset the list, especially useful on mobile to mimick forbidden nesting | |
| lang | LocaleOrLanguageundefined | |||
| listStyleType | ListStyleTypeundefined | By default, inferred from `type` | ||
| maxFontSizeMultiplier | numbernullundefined | |||
| size | 9 possibilitiesundefinednumberVariable<any>"$text100""$text200""$text300""$text400""$text500"Partial<Record<"$xs" | "$ltVs" | "$vs" | "$ltSm" | "$sm" | "$ltMd" | "$md" | "$ltLg" | "$lg" | "$ltXl" | "$xl" | "$ltXxl" | "$xxl", TextSize>> | |||
| sx | 2 possibilitiesundefinedOmit<TextProps, "fontStyle" | "fontFamily" | "fontWeight"> | |||
| type | "inline""ordered""unordered"undefined | unordered | List type: `ol` or `ul`, `'unordered'` by default |
ListNextItem props
| Name | Type | Default Value | Description | Usage count |
|---|---|---|---|---|
| aria-hidden | booleanundefined |
Style API
Use sx for one-off adjustments. It accepts these style keys:
Each can be overridden per breakpoint with: