Skip to main content

List

List is a semantic list component for displaying ordered or unordered items.

Import

import { List, ListItem, ListIcon } from "@tosui/react";

Basic Usage

<List>
<ListItem>First item</ListItem>
<ListItem>Second item</ListItem>
<ListItem>Third item</ListItem>
</List>

Ordered List

<List as="ol">
<ListItem>Step one</ListItem>
<ListItem>Step two</ListItem>
<ListItem>Step three</ListItem>
</List>

Style Types

<VStack gap={6} align="flex-start">
<Box>
<Box fontWeight="medium" mb={2}>None (default for ul)</Box>
<List styleType="none">
<ListItem>Item without bullet</ListItem>
<ListItem>Another item</ListItem>
</List>
</Box>

<Box>
<Box fontWeight="medium" mb={2}>Disc</Box>
<List styleType="disc">
<ListItem>Item with bullet</ListItem>
<ListItem>Another item</ListItem>
</List>
</Box>

<Box>
<Box fontWeight="medium" mb={2}>Decimal (default for ol)</Box>
<List as="ol" styleType="decimal">
<ListItem>Numbered item</ListItem>
<ListItem>Another item</ListItem>
</List>
</Box>
</VStack>

Spacing

<VStack gap={6}>
<Box>
<Box fontWeight="medium" mb={2}>No spacing (default)</Box>
<List styleType="disc" spacing={0}>
<ListItem>First item</ListItem>
<ListItem>Second item</ListItem>
<ListItem>Third item</ListItem>
</List>
</Box>

<Box>
<Box fontWeight="medium" mb={2}>With spacing</Box>
<List styleType="disc" spacing={2}>
<ListItem>First item</ListItem>
<ListItem>Second item</ListItem>
<ListItem>Third item</ListItem>
</List>
</Box>
</VStack>

With Icons

Use ListIcon to add custom icons to list items.

import { CheckIcon, StarIcon } from "your-icon-library";

<List spacing={2}>
<ListItem>
<ListIcon><CheckIcon /></ListIcon>
Feature one
</ListItem>
<ListItem>
<ListIcon><CheckIcon /></ListIcon>
Feature two
</ListItem>
<ListItem>
<ListIcon><StarIcon /></ListIcon>
Premium feature
</ListItem>
</List>

Common Patterns

Feature List

<List spacing={3}>
<ListItem>
<ListIcon><CheckIcon /></ListIcon>
Unlimited users
</ListItem>
<ListItem>
<ListIcon><CheckIcon /></ListIcon>
API access
</ListItem>
<ListItem>
<ListIcon><CheckIcon /></ListIcon>
24/7 support
</ListItem>
<ListItem>
<ListIcon><CheckIcon /></ListIcon>
Custom integrations
</ListItem>
</List>

Steps

<List as="ol" spacing={4}>
<ListItem>
<Box>
<Box fontWeight="medium">Create an account</Box>
<Text fontSize="sm" color="foreground-muted">
Sign up with your email address
</Text>
</Box>
</ListItem>
<ListItem>
<Box>
<Box fontWeight="medium">Verify your email</Box>
<Text fontSize="sm" color="foreground-muted">
Click the link in your inbox
</Text>
</Box>
</ListItem>
<ListItem>
<Box>
<Box fontWeight="medium">Complete your profile</Box>
<Text fontSize="sm" color="foreground-muted">
Add your details and preferences
</Text>
</Box>
</ListItem>
</List>

Props Reference

List

PropTypeDefaultDescription
as"ul" | "ol""ul"HTML list element
styleType"none" | "disc" | "decimal"depends on asList style type
spacingnumber0Gap between items (spacing multiplier)

ListItem

PropTypeDefaultDescription
childrenReactNode-Item content

ListIcon

PropTypeDefaultDescription
childrenReactNode-Icon content

TypeScript

import { List, ListItem, ListIcon, type ListStyleType, type ListProps, type ListItemProps, type ListIconProps } from "@tosui/react";