Search documentation v0.8.1

Scroll Banner

Display a series of images with infinite scroll

Source ↗️ Report Issue ↗️

Use the ScrollBanner component to display horizontally infinitely scrolling images. They’re space efficient and can draw attention to highlight images, most notably partner or client logos, certification, or awards to build credibility and trustworthiness.

Preview - hover to stop the scroll
imgimgimgimgimgimgimg
imgimgimgimgimgimgimg
Unlock code
How to use the ScrollBanner component in Astro
---
const images = [
{
src: '/img/logo.svg',
alt: 'Logo',
width: 125,
height: 200
},
{ ... }
]
---
<ScrollBanner images={images} />

The ScrollBanner component expects a single images prop that describes images in the form of an array of objects. Each object can have the following properties:

Image Size

You can customize the size of the banner by setting the imageSize prop on the component. By default, the height of the images are set to 40px:

Custom image size
imgimgimgimgimgimgimg
imgimgimgimgimgimgimg
Unlock code
Height of images will be set to 25px in this example
<ScrollBanner images={[ ... ]} imageSize={25} />

Animation

The animation of the ScrollBanner component can be configured in many different ways. Use the following props to disable or customize the way your animation works:

No animation
imgimgimgimgimgimgimg
imgimgimgimgimgimgimg
Speed set to 15s
imgimgimgimgimgimgimg
imgimgimgimgimgimgimg
Reverse
imgimgimgimgimgimgimg
imgimgimgimgimgimgimg
Unlock code
How to disable animation
<ScrollBanner images={[ ... ]} animate={false} />
Unlock code
How to set animation speed
<ScrollBanner images={[ ... ]} animationSpeed={15} />
Unlock code
How to reverse scroll direction
<ScrollBanner images={[ ... ]} reverse={true} />

Shadows

The component uses a fade-in, fade-out effect using shadows on each side. The size of the shadows can be customized or even turned off using the shadows and shadowWidth props:

No shadows
imgimgimgimgimgimgimg
imgimgimgimgimgimgimg
Shadow width set to 100px
imgimgimgimgimgimgimg
imgimgimgimgimgimgimg
Unlock code
How to disable shadows
<ScrollBanner images={[ ... ]} shadows={false} />
Unlock code
How to customize shadow size
<ScrollBanner images={[ ... ]} shadowWidth={100} />

Desaturated

The component can also be create with a desaturated effect using the desaturated prop:

Default
imgimgimgimgimgimgimg
imgimgimgimgimgimgimg
Desaturated
imgimgimgimgimgimgimg
imgimgimgimgimgimgimg
Unlock code
How to desaturate images
<ScrollBanner images={[ ... ]} desaturated={true} />

Configure With CSS

Some of the above configurations can also be configured using CSS variables, such as the image size, animation speed, and shadow width. If you need consistent styles across all of your ScrollBanner components, prefer overriding the following CSS variables once:

Unlock code
Override the following CSS variables to customize all of your scroll banners
html body {
--w-scroll-banner-img-size: 40px;
--w-scroll-banner-animation-speed: 30s;
--w-scroll-banner-shadow-width: 50px;
}

API

Unlock code
Component API reference
type ScrollBannerProps = {
images: {
src: string
alt: string
width: number
height: number
lazy?: boolean
}[]
imageSize?: number,
animate?: boolean
animationSpeed?: number
reverse?: boolean
shadows?: boolean
shadowWidth?: number
stopOnHover?: boolean
desaturated?: boolean
className?: string
}
PropDefaultPurpose
images - Sets the images.
images.src - Sets the path for the image.
images.alt - Sets an alternate text for the image.
images.width - Sets the width of the image.
images.height - Sets the height of the image.
images.lazy - Set to true to enable lazy loading for the image.
imageSize 40px Sets the height of the images.
animate true Enables infinite scroll.
animationSpeed 30s Sets the animation speed.
reverse false Reverses the direction of the scroll.
shadows true Adds shadows to the side of the scroll banner.
shadowWidth 50px Sets the width of the shadows.
stopOnHover true Stops the scroll animation on hover.
desaturated false Desaturates images.
className - Pass additional CSS classes for the ScrollBanner component.

Request improvement for this page