Skip to Content
Dashflow Logo

Ol Component

A comprehensive guide to using the Ol component with examples, props, and best practices.


Overview

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.

Basic Usage

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:

  1. First ordered item
  2. Second ordered item
  3. Third ordered item

Props

PropTypeDefaultDescription
classNamestring''Additional CSS classes for the ordered list
childrenReactNode-The list items content

Examples

Basic Ordered List

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:

  1. First ordered item
  2. Second ordered item
  3. Third ordered item

Styled Ordered List

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:

  1. First ordered item
  2. Second ordered item
  3. Third ordered item

Custom Styled Ordered List

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:

  1. First ordered item
  2. Second ordered item
  3. Third ordered item

Nested Ordered List

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:

  1. First ordered item
  2. Second ordered item
  3. Third ordered item

Common Use Cases

Instructions List

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>
);

Process Steps

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>
);

Priority List

const priorityList = (
<Ol>
<li>High priority task</li>
<li>Medium priority task</li>
<li>Low priority task</li>
</Ol>
);

Checklist

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>
);

Ranking List

const rankingList = (
<Ol>
<li>First place winner</li>
<li>Second place winner</li>
<li>Third place winner</li>
</Ol>
);

Best Practices

1. Logical Order

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>

2. Clear Content

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>

3. Consistent Styling

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>

4. Appropriate Nesting

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>

5. Accessible Content

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>

Customization

Custom Styling

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>

Different Themes

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" />

Size Variations

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" />

Advanced Usage

Dynamic List Items

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>

Conditional Styling

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>

Interactive List Items

Make list items interactive:

const [selectedItem, setSelectedItem] = useState(null);
<Ol>
<li
className={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

API Reference

For the complete API reference and advanced usage patterns, see the Ol API documentation.

Edit this page on GitHub