List
A component for displaying items with consistent styling.
List
A component that organizes items with various styling options including plain, separated, or divided variants.
Import
Features
- Multiple visual variants (plain, separated, divided)
- Customizable spacing between items
- Accepts any React components as children
- Dark mode compatible
- Customizable with Tailwind classes
Props
Prop | Type | Default | Description |
---|---|---|---|
variant | 'plain' | 'separated' | 'divided' | 'plain' | Visual style of the list |
spacing | number | 0 | Gap between list items in pixels |
className | string | '' | Additional Tailwind classes |
style | ViewStyle | — | Additional style object |
children | React.ReactNode | — | List items to render |
Basic Usage
List Variants
Plain
The default variant with no decorations, suitable for simple lists:
Divided
Adds dividers between list items, ideal for settings or menus:
Separated
Creates visual separation between items without lines, useful for card-like items:
Best Practices
Choose the Right Variant
Select the appropriate variant based on your content type:
Consistent Item Structure
Maintain consistent structure across list items for better UX:
Pair with Section Component
Use List with the Section component for organized content hierarchies:
Implementation Details
The List component uses React Native's View
component as a container for list items. It applies different styling based on the selected variant:
- Plain: No additional styling, just renders items with specified spacing
- Separated: Similar to plain but with semantic separation (no dividers)
- Divided: Adds dividers between items using Tailwind's
divide-y
utility
The component handles spacing between items using the gap property in the style object, which provides consistent spacing regardless of the variant chosen.
The List component automatically adapts to dark mode for divided variants, using appropriate divider colors that work in both light and dark themes.
Notes
- The List component doesn't add any padding by default; add padding to individual list items or to the List itself via className
- When using the divided variant, remember that the divider color automatically adapts to dark mode
- For advanced customization, combine with custom item components or wrap in a Card for elevated list sections