Divider
A flexible divider component that can be used to separate content with optional labels, icons, and various styles.
Overview
The Divider component is used to create visual separation between content sections. It supports both horizontal and vertical orientations, various styles, and can include optional labels or icons.
Features
- Multiple visual variants (solid, dashed, dotted, gradient)
- Horizontal and vertical orientations
- Different sizes (xs to xl)
- Optional label or icon
- Color variations
- Customizable appearance
Usage
Basic Divider
The simplest way to use the divider is without any content:
<template>
<MDivider />
</template>
With Label
Add text labels to provide context:
<template>
<MDivider label="OR" />
<MDivider label="Section Break" />
</template>
With Icon
Use icons for visual separation:
<template>
<MDivider icon="i-lucide-star" />
<MDivider icon="i-lucide-heart" />
</template>
Variants
Different border styles for various contexts:
<template>
<MDivider variant="solid" label="Solid" />
<MDivider variant="dashed" label="Dashed" />
<MDivider variant="dotted" label="Dotted" />
<MDivider variant="gradient" label="Gradient" />
</template>
Colors
Choose between different colors:
<template>
<MDivider color="neutral" label="Neutral" />
<MDivider color="primary" label="Primary" />
</template>
Sizes
Available in different thicknesses:
<template>
<MDivider size="xs" label="Extra Small" />
<MDivider size="sm" label="Small" />
<MDivider size="md" label="Medium" />
<MDivider size="lg" label="Large" />
<MDivider size="xl" label="Extra Large" />
</template>
Vertical Orientation
Use vertical dividers to separate inline content:
Content
More Content
Extra Content
<template>
<div class="h-32 flex items-center justify-center gap-4">
Content
<MDivider orientation="vertical" />
More Content
<MDivider orientation="vertical" label="OR" />
Extra Content
</div>
</template>
Props
Text to display in the center of the divider.
Icon to display in the center of the divider.
The color scheme of the divider.
The thickness of the divider line.
The visual style of the divider line.
The orientation of the divider.
Additional CSS classes to apply to the root element.
Additional CSS classes to apply to the border element.
Additional CSS classes to apply to the label.
Additional CSS classes to apply to the icon.
Slots
Custom content to display in the center of the divider.
Best Practices
- Visual separation:
- Use dividers sparingly to avoid cluttering the interface
- Choose appropriate variants for the context
- Maintain consistent styling within sections
- Content organization:
- Use labels to provide meaningful context
- Keep labels concise and clear
- Consider using icons for visual hierarchy
- Spacing considerations:
- Maintain consistent spacing around dividers
- Adjust size based on content importance
- Consider responsive behavior
- Accessibility:
- Ensure sufficient color contrast
- Use semantic markup when possible
- Consider screen reader users
- Layout guidelines:
- Use horizontal dividers for section breaks
- Use vertical dividers for inline content separation
- Maintain alignment with surrounding content