List
React List components are used to display a collection of related items. They are commonly used for navigation menus, settings panels, item groups, and structured content lists.
This List component is built with React and styled using Tailwind CSS. It supports vertical and horizontal layouts, dividers, and active item states.
- Home
- About
- Services
- Contact
- Dashboard3
- Settings
- Profile
- Logout
Installation
Install the component using the Tailgrids CLI.
npx @tailgrids/cli add listUsage
Import the component and render list items as children.
import { List } from "@/registry/core/list";
export default function Example() {
return (
<List>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</List>
);
}Examples
Vertical List
Use the vertical layout for stacked navigation or menus.
- Dashboard
- Settings
- Profile
- Logout
Note: Vertical lists have a max width of 228px (14.25rem).
Horizontal List
Use the horizontal layout for inline navigation or filters.
- Home
- About
- Contact
Note: Horizontal lists have a max width of fit-content.
Without Dividers
You can remove dividers when visual separation is not needed. Dividers can be hidden with the hideDividers prop.
- Item 1
- Item 2
- Item 3
With Active State
Mark an item as active to indicate the current selection.
- Dashboard
- Settings
- Profile
Note: Active items are styled with primary background and text color. Active state is communicated via data-active attribute.
Custom
Combine icons, count badges, and different layouts to create rich list components.
- Messages12
- Notifications5
- Settings
- Home
- Profile
- Settings
Note: Counts with data-type="count" are automatically positioned with ml-auto. Icons automatically inherit the current text color.
API Reference
List
Extends ul element props.
| Prop | Type | Default | Description |
|---|---|---|---|
direction | 'vertical', 'horizontal' | 'vertical' | List layout direction |
hideDividers | boolean | false | Hide dividers between items |
children | React.ReactNode | - | List items (<li> elements) |
List Item
Use standard <li> elements as children with optional data attributes:
| Attribute | Type | Description |
|---|---|---|
data-active | boolean | Marks item as active (applies primary styling) |
data-type="count" | - | Applied to <span> for count badges (auto-positioned to right) |
Accessibility
- Uses semantic
<ul>and<li>elements - Active state is communicated via
data-activeattribute - Hover states provide clear visual feedback and apply to all list items by default
- Keyboard accessible when used with interactive elements
- Icons inherit text color for consistent styling