InfiniteLogoCarousel shows a row of client, partner or technology logos. Turn on EnableAutoScroll and the row
loops continuously; leave it off for a static row. Logos can link somewhere and can have separate light and dark
images.
Usage
The enhancement script loads through the BlazorJSComponents package. Register its services once in Program.cs:
builder.Services.AddJSComponents();
Always pass your own logos. Without CustomLogos, the component shows built-in sample logos with placeholder links.
@using Osirion.Blazor.Components
<InfiniteLogoCarousel CustomLogos="logos" SectionTitle="Our clients" />
@code {
private readonly LogoItem[] logos =
[
new("/images/clients/northwind.svg", "Northwind Traders"),
new("/images/clients/fabrikam.svg", "Fabrikam"),
new("/images/clients/adventure-works.svg", "Adventure Works"),
];
}
A looping strip with a heading, links and a logo that has light and dark versions:
<InfiniteLogoCarousel Title="Trusted by teams like these"
SectionTitle="Client logos"
CustomLogos="logos"
EnableAutoScroll="true"
AnimationDuration="40"
LogoWidth="160"
LogoHeight="64" />
@code {
private readonly LogoItem[] logos =
[
new("/images/clients/northwind.svg", "Northwind Traders", Url: "/customers/northwind", Target: "_self"),
new("/images/clients/contoso-light.svg", "Contoso",
LightImageUrl: "/images/clients/contoso-light.svg",
DarkImageUrl: "/images/clients/contoso-dark.svg"),
new("/images/clients/fabrikam.svg", "Fabrikam", EnableGrayscale: false),
];
}
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
CustomLogos |
IReadOnlyList<LogoItem>? |
null |
The logos. When null, built-in sample logos are shown. |
Title |
string? |
null |
Heading shown above the logos, as an <h2>. |
SectionTitle |
string |
"Our Clients" |
Accessible name (aria-label) of the <section>. |
EnableAutoScroll |
bool |
false |
Loops the row continuously with a CSS animation. |
AnimationDuration |
int |
60 |
Seconds for one full loop when EnableAutoScroll is on. Lower is faster. |
Direction |
AnimationDirection |
Right |
Right moves the logos from right to left; Left moves them from left to right. |
PauseOnHover |
bool |
true |
Pauses the loop while the pointer is over the carousel. |
EnableGrayscale |
bool |
true |
Shows logos in grayscale until hovered. A logo can override it. |
LogoWidth |
int |
200 |
Width of each logo slot in pixels; also the images' width attribute. |
LogoHeight |
int |
80 |
Height of each logo slot in pixels; also the images' height attribute. |
LogoGap |
int |
24 |
Gap between logos in pixels. |
MaxVisibleLogos |
int? |
null |
Shows only the first N logos. |
ChildContent |
RenderFragment? |
null |
Extra content rendered as one more item after the logos. |
Class |
string? |
null |
Extra classes on the <section>. |
Style |
string? |
null |
Inline style on the <section>. |
Theme |
ThemeMode |
System |
Dark makes logos with light and dark images use the dark image inside this carousel. |
Unmatched attributes go on the <section>.
LogoItem
LogoItem is a record: new LogoItem(ImageUrl, AltText, ...) with the optional values named.
| Value | Type | Default | Description |
|---|---|---|---|
ImageUrl |
string |
required | The logo image. Not used when both light and dark images are set. |
AltText |
string |
required | The image's alt text, and the link's title when the logo links. |
LightImageUrl |
string? |
null |
Image for the light theme. |
DarkImageUrl |
string? |
null |
Image for the dark theme. Both must be set for the light and dark switch to apply. |
Url |
string? |
null |
Makes the logo a link. |
Target |
string? |
"_blank" when linked |
The link's target. |
NoFollow |
bool? |
true when linked |
Adds nofollow to rel. |
NoOpener |
bool? |
true when linked |
Adds noopener to rel. |
EnableGrayscale |
bool? |
null |
Overrides the carousel's EnableGrayscale for this logo. |
Behavior
- Without script the logos render as a list. Logos that do not fit the width are cut off at the faded edges, so
either keep a static row short or turn on
EnableAutoScroll. With auto-scroll, the CSS animation runs without script. - With script, the logo nearest the center and its two neighbors are shown in color when
EnableGrayscaleis on. With auto-scroll on, the visitor can also drag the row or scroll it with a horizontal wheel or trackpad gesture, and a pause button appears in the top right corner. - Pausing. Hover pauses the loop when
PauseOnHoveris on; keyboard focus inside the carousel always pauses it. Underprefers-reduced-motion: reducethe loop does not run. - Accessibility. The
<section>is named bySectionTitle, so set it to something that describes the logos. The logos are a list. With auto-scroll on, a second copy of the logos closes the loop; it isaria-hiddenandinert, so screen readers read each logo once and the copy's links are not in the tab order. Translate the pause button withdata-pause-labelanddata-play-labelattributes, which go on the<section>. - Dark mode. For a logo with both light and dark images, CSS shows the dark image when an ancestor has
data-bs-theme="dark",data-theme="dark"or one of the classesdark-theme,theme-darkorosirion-theme-dark, and followsprefers-color-schemewhen the<html>element has no theme attribute. - Links. Logo links open in a new tab with
rel="nofollow noopener"unless the logo says otherwise.Urlis written as given, so pass only URLs you trust. - Images load lazily and cannot be dragged as files, so dragging moves the row.
Styling
| Class or property | Purpose |
|---|---|
osirion-infinite-carousel |
The <section> |
osirion-carousel-title |
The heading |
osirion-carousel-list |
A list of logos |
osirion-logo-item |
A logo slot |
osirion-logo-grayscale, osirion-logo-dual |
Added to slots with grayscale or light and dark images |
osirion-carousel-content-item |
The slot holding ChildContent |
osirion-carousel-pause |
The pause button the script adds |
--osirion-carousel-duration, --osirion-logo-width, --osirion-logo-height, --osirion-logo-gap |
Set from the parameters of the same names |
The heading and the pause button use the theme's --osirion-text-primary, --osirion-background and font size
tokens, and the focus ring uses --osirion-focus-ring-width and --osirion-focus-ring-color. Below 768px, logo
slots shrink to 160px wide.
Related
Related Articles
