Divider
A customizable divider component for creating visual separation between content sections.
Divider
The Divider component provides a simple way to create visual separation between content sections. It can be oriented horizontally or vertically with customizable styling options.
Features
- Orientation Options: Horizontal or vertical layout
- Customizable Color: Set custom divider colors
- Adjustable Thickness: Control the divider's weight
- Spacing Control: Add margin around the divider
- Styling Control: Accepts additional Tailwind classes and style objects
- Dark Mode Support: Uses theme-aware colors by default
Import
Props
Prop | Type | Default | Description |
---|---|---|---|
orientation | 'horizontal' | 'vertical' | 'horizontal' | Direction of the divider |
color | string | Theme border color | Color of the divider |
thickness | number | 1 | Thickness of the divider in points |
spacing | number | 0 | Margin around the divider (vertical for horizontal dividers, horizontal for vertical dividers) |
className | string | '' | Additional Tailwind classes |
style | ViewStyle | — | Additional style object |
Usage Examples
Basic Horizontal Divider
Divider with Spacing
Custom Styled Divider
Vertical Divider
Form Section Example
Card Component Example
List Example with Dividers
Side-by-Side Layout Example
Best Practices
Use for Content Separation
Use dividers to create logical separation between different content sections:
Consistent Styling
Maintain consistent divider styling throughout your application:
Use with List Components
Use dividers to separate list items for better visual clarity:
Implementation Details
The Divider component uses React Native's View
component with custom styling to create a horizontal or vertical line. The color defaults to the theme's border color from the useThemeColors
hook, ensuring proper appearance in both light and dark modes.
For horizontal dividers, the component spans the full width of its container and has a height determined by the thickness
prop. For vertical dividers, it spans the full height of its container with a width determined by the thickness
prop.
The spacing
prop adds appropriate margin based on the divider's orientation (vertical margin for horizontal dividers, horizontal margin for vertical dividers).
Notes
- Horizontal dividers stretch to fill the width of their container
- Vertical dividers need a container with a defined height to be visible
- The default color adapts to the current theme (light/dark)
- For more complex dividers with content (like "or" dividers), consider creating a custom component
- Use the
spacing
prop to add margin around the divider rather than wrapping it in additional Views