Marquee
A customizable marquee component with horizontal and vertical scrolling, reverse directions, and pause-on-hover support.
Introduction
The Marquee
component creates smooth scrolling content in either horizontal or vertical orientation, perfect for showcasing content in a dynamic, space-efficient manner. It supports customizable speeds, directions, and interactions like pausing on hover.
Horizontal Marquee
Customize Your Marquee
Vertical Marquee
Installation
Quickly add the component using:
File Structure
Props
Prop | Type | Default |
---|---|---|
className | string | - |
reverse | boolean | false |
pauseOnHover | boolean | false |
children | ReactNode | - |
vertical | boolean | false |
repeat | number | 4 |
style | React.CSSProperties | - |
Advanced Usage
Customizing Animation Speed
You can adjust the scroll speed by changing the CSS --duration
variable:
Adjusting Item Spacing
Modify the gap between items using the --gap
CSS variable:
Carousel-like Implementation
By combining with other components, you can create more complex scroll experiences:
News Ticker Example
Create a news ticker with the marquee component:
Accessibility
Keep these accessibility considerations in mind when using the Marquee component:
- Motion Sensitivity: Automatically moving content may cause issues for users with vestibular disorders. Consider providing a way to pause or disable animations site-wide.
- Screen Reader Support: Make sure the scrolling content is accessible to screen readers.
- Alternative View: For critical information, provide an alternative, static view for users who prefer reduced motion.
Conclusion
The Marquee
component offers a flexible and customizable way to create scrolling content in both horizontal and vertical directions. It’s perfect for showcasing related items, creating news tickers, or adding dynamic visual interest to your application with minimal effort.