The Ol component provides a styled ordered list element with consistent spacing and typography. It's designed to display numbered lists with proper indentation and styling.
import { Ol } from '@dashflowx/core'export default function OlExample() {return (<Ol><li>First item</li><li>Second item</li><li>Third item</li></Ol>)}
Preview:
- First ordered item
- Second ordered item
- Third ordered item
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | '' | Additional CSS classes for the ordered list |
children | ReactNode | - | The list items content |
import { Ol } from '@dashflowx/core'export default function BasicOl() {return (<Ol><li>Step 1: Prepare ingredients</li><li>Step 2: Mix ingredients</li><li>Step 3: Cook for 30 minutes</li></Ol>)}
Preview:
- First ordered item
- Second ordered item
- Third ordered item
import { Ol } from '@dashflowx/core'export default function StyledOl() {return (<Ol className="text-blue-600 font-semibold"><li>First styled item</li><li>Second styled item</li><li>Third styled item</li></Ol>)}
Preview:
- First ordered item
- Second ordered item
- Third ordered item
import { Ol } from '@dashflowx/core'export default function CustomStyledOl() {return (<Ol className="text-lg font-bold text-purple-600 border-l-4 border-purple-600 pl-4"><li>Custom styled item 1</li><li>Custom styled item 2</li><li>Custom styled item 3</li></Ol>)}
Preview:
- First ordered item
- Second ordered item
- Third ordered item
import { Ol } from '@dashflowx/core'export default function NestedOl() {return (<Ol><li>Main step 1</li><li>Main step 2</li><Ol className="ml-4"><li>Sub step 2.1</li><li>Sub step 2.2</li></Ol><li>Main step 3</li></Ol>)}
Preview:
- First ordered item
- Second ordered item
- Third ordered item
const instructionsList = (<Ol><li>Read the instructions carefully</li><li>Gather all required materials</li><li>Follow each step in order</li><li>Test the final result</li></Ol>);
const processSteps = (<Ol><li>Initial consultation</li><li>Requirements gathering</li><li>Design and planning</li><li>Development phase</li><li>Testing and quality assurance</li><li>Deployment and launch</li></Ol>);
const priorityList = (<Ol><li>High priority task</li><li>Medium priority task</li><li>Low priority task</li></Ol>);
const checklist = (<Ol><li>Review project requirements</li><li>Create project timeline</li><li>Assign team members</li><li>Set up development environment</li><li>Begin development work</li></Ol>);
const rankingList = (<Ol><li>First place winner</li><li>Second place winner</li><li>Third place winner</li></Ol>);
Ensure list items are in logical order.
// ✅ Good - Logical order<Ol><li>Step 1: Prepare</li><li>Step 2: Mix</li><li>Step 3: Cook</li></Ol>// ❌ Avoid - Illogical order<Ol><li>Step 3: Cook</li><li>Step 1: Prepare</li><li>Step 2: Mix</li></Ol>
Use clear and descriptive content for list items.
// ✅ Good - Clear content<Ol><li>Complete the registration form</li><li>Verify your email address</li><li>Set up your profile</li></Ol>// ❌ Avoid - Unclear content<Ol><li>Do stuff</li><li>More stuff</li><li>Final stuff</li></Ol>
Maintain consistent styling across your lists.
// ✅ Good - Consistent styling<Ol className="standard-ol-style"><li>Item 1</li><li>Item 2</li></Ol>// ❌ Avoid - Inconsistent styling<Ol className="random-styles"><li>Item 1</li><li>Item 2</li></Ol>
Use appropriate nesting levels for hierarchical content.
// ✅ Good - Appropriate nesting<Ol><li>Main step</li><Ol><li>Sub step</li></Ol></Ol>// ❌ Avoid - Too deep nesting<Ol><li>Main step</li><Ol><li>Sub step</li><Ol><li>Sub-sub step</li><Ol><li>Sub-sub-sub step</li></Ol></Ol></Ol></Ol>
Ensure list content is accessible to all users.
// ✅ Good - Accessible content<Ol><li>Clear and descriptive step</li></Ol>// ❌ Avoid - Unclear content<Ol><li>Click here</li></Ol>
You can customize the ordered list appearance using CSS classes:
<Ol className="text-lg font-bold text-blue-600 border-l-4 border-blue-600 pl-4"><li>Custom styled item</li></Ol>
Use different themes for different contexts:
// Light theme<Ol className="text-gray-900" />// Dark theme<Ol className="text-white" />// Brand theme<Ol className="text-blue-600" />
Use different sizes for different emphasis levels:
// Small ordered list<Ol className="text-sm" />// Standard ordered list<Ol className="text-base" />// Large ordered list<Ol className="text-lg" />
Create dynamic list items based on data:
const steps = ['Prepare', 'Mix', 'Cook', 'Serve'];<Ol>{steps.map((step, index) => (<li key={index}>Step {index + 1}: {step}</li>))}</Ol>
Apply conditional styling based on state:
const [isCompleted, setIsCompleted] = useState(false);<Ol className={isCompleted ? 'text-green-600' : 'text-gray-600'}><li>Task item</li></Ol>
Make list items interactive:
const [selectedItem, setSelectedItem] = useState(null);<Ol><liclassName={selectedItem === 'item1' ? 'bg-blue-100' : ''}onClick={() => setSelectedItem('item1')}>Interactive item</li></Ol>
- Ul: For unordered lists
- Li: For list items
- List: For list containers
- Typography: For text styling
- Button: For interactive list items
For the complete API reference and advanced usage patterns, see the Ol API documentation.
