Skip to content

Marquee

The Marquee component provides a modern implementation of scrolling text or content, similar to the classic HTML marquee element but with more features and control options. It supports multiple directions, easing functions, and animation modes.

  • @olton/farbe - Color utility library
<div data-role="marquee">
Item 1
Item 2
Item 3
</div>
<div data-role="marquee"
data-duration="4000"
data-direction="left"
data-height="100"
data-mode="accent"
data-ease="easeOutBounce easeInElastic">
<div>Hi Guys!</div>
<div>This is a demo of Marquee component</div>
<div>Marquee support different directions</div>
<div>You can define colors for marquee</div>
<div>Use <code>accent</code> mode to accenting</div>
</div>
<div id="my-marquee" data-role="marquee"></div>
<script>
var items = [
'Item 1',
'Item 2',
'Item 3'
];
$(function(){
var marquee = Metro.getPlugin('#my-marquee', 'marquee');
marquee.setItems(items);
});
</script>
ParameterTypeDefaultDescription
itemsarraynullItems to display in the marquee (alternative to HTML content)
loopbooleantrueWhether to loop the marquee animation
heightstring”auto”Height of the marquee container
widthstring”100%“Width of the marquee container
durationnumber10000Duration of the animation in milliseconds
directionstring”left”Direction of the marquee (“left”, “right”, “up”, “down”)
easestring”linear”Easing function for the animation
modestring”default”Mode of the marquee (“default” or “accent”)
accentPausenumber2000Pause time for accent mode in milliseconds
firstPausenumber1000Pause time before the first item in milliseconds
stopOnHoverbooleantrueWhether to stop the marquee on hover
splitBystring”\n”Character to split text content by when using plain text
clsMarqueestring""Additional CSS class for the marquee container
clsMarqueeItemstring""Additional CSS class for marquee items
  • setItems(items, replace) - Sets the items for the marquee. If replace is true (default), replaces all existing items.
  • setItem(index, value) - Sets a specific item at the given index.
  • addItem(item, index) - Adds an item to the marquee. If index is provided, inserts at that position, otherwise appends to the end.
  • start() - Starts the marquee animation.
  • stop() - Stops the marquee animation.
  • destroy() - Destroys the marquee component.
const marquee = Metro.getPlugin('#my-marquee', 'marquee');
// Set new items
marquee.setItems(['New Item 1', 'New Item 2'], true);
// Update a specific item
marquee.setItem(0, 'Updated Item');
// Add a new item
marquee.addItem('Additional Item');
// Stop and start the animation
marquee.stop();
marquee.start();
EventDescription
onMarqueeItemTriggered when a marquee item is shown
onMarqueeItemCompleteTriggered when a marquee item animation is complete
onMarqueeCompleteTriggered when the marquee animation is complete
onMarqueeCreateTriggered when the marquee is created
  • .marquee - Base class for the component
  • .marquee__item - Class for each marquee item
  • .moveLeftRight - Class for items moving left or right
  • .moveUpDown - Class for items moving up or down
/* Custom styling example */
.my-custom-marquee {
border: 1px solid #ddd;
padding: 10px;
margin: 10px 0;
height: 100px;
}
.my-custom-marquee .marquee__item {
font-weight: bold;
color: #0366d6;
}
  1. Use appropriate duration values based on the length of your content
  2. Consider using the stopOnHover option to improve user experience
  3. For vertical scrolling, set an explicit height for the marquee container
  4. Use the accent mode for important announcements that need user attention
  5. For responsive designs, consider adjusting the duration based on screen size