Directory
- Welcome
List Component
The List component provides a flexible foundation for creating structured, accessible lists with optional icons and custom styling. Perfect for feature lists, navigation menus, and content organization.
Key Features
-
Flexible Structure: Support for both simple text and complex content
-
Icon Integration: Optional icons with customizable styling
-
Accessibility: Semantic HTML structure with proper list markup
-
Customization: Extensive styling options and props
Basic Usage
Create lists using either the simplified array approach or individual list items when complex content is needed:
<List listItems={['First Item', 'Second Item', 'Third Item']} /><!-- Using listItems prop -->
<List> <ListItem>First Item</ListItem> <ListItem>Second Item</ListItem> <ListItem>Third Item</ListItem></List><!-- Using ListItem components -->
Icon Integration
Add visual hierarchy with icons:
---import checkIcon from '@/assets/icons/check-circle.svg?raw';---
<List> <ListItem icon={checkIcon}>Default icon alignment</ListItem> <ListItem icon={checkIcon}>Consistent spacing</ListItem> <ListItem icon={checkIcon}>Automatic sizing</ListItem></List>
Custom Icon Styling
-
Custom icon styling
-
Multiple icon options
<List> <ListItem icon={star} iconProps={{ class: 'text-secondary' }}> Custom icon styling </ListItem> <ListItem icon={arrow} iconProps={{ class: 'text-success' }}> Multiple icon options </ListItem></List>
Complex Content
Lists support rich content within items:
-
Feature Title
Detailed description of the feature goes here.
-
Another Feature
Can include any HTML content or components.
<List class="[&_icon]:mt-1 sm:[&_icon]:mt-1.5"> <ListItem icon={checkIcon}> <div> <h3>Feature Title</h3> <p class="text-txt-secondary text-sm">Detailed description of the feature.</p> </div> </ListItem> <ListItem icon={checkIcon}> <div> <h3>Another Feature</h3> <p class="text-txt-secondary text-sm">Can include any HTML content.</p> </div> </ListItem></List>
Component API
List Props
Prop | Type | Default | Description |
---|---|---|---|
listItems | string[] | [] | Array of simple text items |
icon | string | Default icon for all items in the listItems prop | |
iconProps | ComponentProps<typeof Icon> | Props passed to all icons | |
listItemProps | HTMLAttributes<"li"> | Props passed to all list items |
ListItem Props
Prop | Type | Default | Description |
---|---|---|---|
icon | string | Icon for this specific item | |
iconProps | ComponentProps<typeof Icon> | Props for this item's icon |
Common Use Cases
Limited Time Launch Sale
Start building structured, accessible content today with our List component. Get the AstroJS starter template and enhance your content organization instantly.
GET 60% OFF!