The Hr component provides a styled horizontal rule element for separating content sections. It's commonly used to create visual breaks between different parts of your content.
import { Hr } from '@dashflowx/core'export default function HrExample() {return (<div><p>Content above</p><Hr /><p>Content below</p></div>)}
Preview: <div> <p>Content above</p>
<p>Content below</p> </div>
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | '' | Additional CSS classes for the horizontal rule |
import { Hr } from '@dashflowx/core'export default function BasicHr() {return (<div><h2>Section 1</h2><p>Content for section 1</p><Hr /><h2>Section 2</h2><p>Content for section 2</p></div>)}
Preview: <div> <h2>Section 1</h2> <p>Content for section 1</p>
<h2>Section 2</h2> <p>Content for section 2</p> </div>
import { Hr } from '@dashflowx/core'export default function StyledHr() {return (<div><h2>Section 1</h2><p>Content for section 1</p><Hr className="border-blue-500 border-2" /><h2>Section 2</h2><p>Content for section 2</p></div>)}
Preview: <div> <h2>Section 1</h2> <p>Content for section 1</p>
<h2>Section 2</h2> <p>Content for section 2</p> </div>
import { Hr } from '@dashflowx/core'export default function CustomStyledHr() {return (<div><h2>Section 1</h2><p>Content for section 1</p><Hr className="border-green-500 border-4 my-8" /><h2>Section 2</h2><p>Content for section 2</p></div>)}
Preview: <div> <h2>Section 1</h2> <p>Content for section 1</p>
<h2>Section 2</h2> <p>Content for section 2</p> </div>
import { Hr } from '@dashflowx/core'export default function GradientHr() {return (<div><h2>Section 1</h2><p>Content for section 1</p><Hr className="border-0 h-1 bg-gradient-to-r from-blue-500 to-purple-600" /><h2>Section 2</h2><p>Content for section 2</p></div>)}
Preview: <div> <h2>Section 1</h2> <p>Content for section 1</p>
<h2>Section 2</h2> <p>Content for section 2</p> </div>
const sectionSeparator = (<div><h2>Introduction</h2><p>Introduction content</p><Hr /><h2>Main Content</h2><p>Main content</p></div>);
const articleDivider = (<div><h1>Article Title</h1><p>Article introduction</p><Hr /><h2>Article Body</h2><p>Article content</p></div>);
const formDivider = (<div><h3>Personal Information</h3><input type="text" placeholder="Name" /><Hr /><h3>Contact Information</h3><input type="email" placeholder="Email" /></div>);
const listSeparator = (<div><h3>Category 1</h3><ul><li>Item 1</li><li>Item 2</li></ul><Hr /><h3>Category 2</h3><ul><li>Item 3</li><li>Item 4</li></ul></div>);
Use horizontal rules to separate semantically different content.
// ✅ Good - Semantic separation<h2>Introduction</h2><p>Introduction content</p><Hr /><h2>Main Content</h2><p>Main content</p>// ❌ Avoid - Decorative use<p>Paragraph 1</p><Hr /><p>Paragraph 2</p>
Use consistent spacing around horizontal rules.
// ✅ Good - Consistent spacing<Hr className="my-8" />// ❌ Avoid - Inconsistent spacing<Hr className="my-2" /><Hr className="my-12" />
Use styling that matches your design system.
// ✅ Good - Consistent styling<Hr className="border-gray-200" />// ❌ Avoid - Random styling<Hr className="border-red-500 border-8" />
Ensure horizontal rules are accessible to screen readers.
// ✅ Good - Accessible<Hr />// ❌ Avoid - Hidden from screen readers<Hr className="sr-only" />
Use responsive spacing for different screen sizes.
// ✅ Good - Responsive spacing<Hr className="my-4 md:my-8" />// ❌ Avoid - Fixed spacing<Hr className="my-8" />
You can customize the horizontal rule appearance using CSS classes:
<Hr className="border-2 border-blue-500 my-12" />
Use different themes for different contexts:
// Light theme<Hr className="border-gray-200" />// Dark theme<Hr className="border-gray-700" />// Brand theme<Hr className="border-blue-500" />
Use different sizes for different emphasis levels:
// Thin line<Hr className="border-t border-gray-200" />// Medium line<Hr className="border-t-2 border-gray-200" />// Thick line<Hr className="border-t-4 border-gray-200" />
Apply dynamic styling based on conditions:
const [isActive, setIsActive] = useState(false);<Hr className={`${isActive ? 'border-blue-500' : 'border-gray-200'}`} />
Show horizontal rules conditionally:
{showSeparator && <Hr />}
Create custom horizontal rule components:
const CustomHr = ({ color, thickness }) => (<Hr className={`border-${thickness} border-${color}`} />);
- Separator: For more flexible separators
- Divider: For content dividers
- Spacer: For spacing elements
- Card: For content containers
- Section: For content sections
For the complete API reference and advanced usage patterns, see the Hr API documentation.
