BlazorHorizontalScroller 1.0.8
See the version list below for details.
dotnet add package BlazorHorizontalScroller --version 1.0.8
NuGet\Install-Package BlazorHorizontalScroller -Version 1.0.8
<PackageReference Include="BlazorHorizontalScroller" Version="1.0.8" />
<PackageVersion Include="BlazorHorizontalScroller" Version="1.0.8" />
<PackageReference Include="BlazorHorizontalScroller" />
paket add BlazorHorizontalScroller --version 1.0.8
#r "nuget: BlazorHorizontalScroller, 1.0.8"
#:package BlazorHorizontalScroller@1.0.8
#addin nuget:?package=BlazorHorizontalScroller&version=1.0.8
#tool nuget:?package=BlazorHorizontalScroller&version=1.0.8
π¦ BlazorHorizontalScroller
A lightweight horizontal scroller component for Blazor WebAssembly and Blazor Server apps. Supports inertia-based dragging, snapping, item spacing, overflow control, and carousel mode β with smooth, touch-friendly interactions powered by JavaScript interop.
It is meant to be a super lightweight version of Slick Carousel, so I didn't include fancy stuff, but you can code some yourself using the callbacks.
This nuget is subject to big changes, use with precaution.
Big thanks to ChatGPT for assisting in creating this component!
β¨ Features
- No external dependencies
- Carousel mode with responsive slides-per-view control
- Customizable overflow behavior
- Optional inertia and decay-based drag scrolling
- Snap-to-item enabled by default with configurable delay
- Supports mouse, touch, and programmatic scrolling
π¦ Installation
Add the NuGet package to your project:
dotnet add package BlazorHorizontalScroller
Then, add this in the file you want to use
@using BlazorHorizontalScroller
π§ Usage
Basic Example
<HorizontalScroller Items="myItems">
<ItemTemplate>
<div>
@context
</div>
</ItemTemplate>
</HorizontalScroller>
Sliding cards overflowing example
When using AllowOverflow=true, you should style some ancestor with overflow-x: hidden;
to delimit the overflow. It will avoid the overflow going out of the page. But don't set it on the body tag, as this will prevent your whole page from using position: sticky;
.
<HorizontalScroller Items="myItems"
ItemTemplate="item => @<div class='card' style='width: 70vw;max-width: 70vw;'>@item</div>"
ItemSpacing="2rem"
AllowOverflow="true" />
Carousel example
@using BlazorHorizontalScroller
<HorizontalScroller Items="myItems"
ItemTemplate="item => @<div class='card'>@item</div>"
CarouselMode="true"
CarouselItemsPerSlideSelector="info => info!.ViewportWidth > 800 ? 3 : 1" />
π Parameters
Parameter | Type | Default | Description |
---|---|---|---|
Items |
IEnumerable<TItem> |
Required | Collection of items to render |
ItemTemplate |
RenderFragment<TItem> |
Required | Template for each item |
ItemSpacing |
string |
"1rem" |
Spacing between items |
AllowOverflow |
bool |
false |
Allow horizontal overflow |
OverflowViewportWidth |
string |
"100%" |
Width of the viewport when overflow is enabled |
OverflowAllowedWidthOnLeft |
string |
"10rem" |
Width of allowed overflow on the left |
EndSpacerWidth |
string |
"300px" |
Space after the last item |
EnableInertia |
bool |
true |
Enable inertia scrolling |
InertiaDecay |
double |
0.9 |
Decay rate of inertia |
EnableDrag |
bool |
true |
Enable drag interactions |
EnableSnapping |
bool |
true |
Snap to the nearest item after drag |
SnapDelay |
int |
100 |
Delay before snapping (ms) |
CarouselMode |
bool |
false |
Enable carousel-like behavior |
CarouselItemsPerSlideSelector |
Func<WidthInfo?, int> |
_ => 1 |
Number of items per slide based on viewport width |
OnSnappedToIndex |
EventCallback<int> |
β | Invoked when snapped to an item |
SelectedIndex |
int |
0 |
Sets the selected slide index |
SelectedIndexChanged |
EventCallback<int> |
β | Callback invoked when selected index changes |
π± Methods
Method | Description |
---|---|
SnapToNextAsync() |
Programmatically snap to the next item |
SnapToPreviousAsync() |
Programmatically snap to the previous item |
SnapToIndexAsync() |
Programmatically snap to the selected slide index (not item index) |
π WidthInfo
Struct
public record WidthInfo(double ParentWidth, double ViewportWidth);
Useful for responsive calculations in your CarouselItemsPerSlideSelector
delegate.
π Notes
- When
AllowOverflow
istrue
, you might need to applyoverflow-x: hidden
to a parent container to prevent unwanted page scrollbars. - The component relies on a JS module (
horizontalScroller.min.js
) for drag, inertia, and snapping behavior. Make sure itβs properly published in your_content/BlazorHorizontalScroller/
directory.
π£ License
MIT License β free to use, modify, and distribute.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.AspNetCore.Components.Web (>= 8.0.16)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.0.30 | 198 | 8/5/2025 |
1.0.29 | 192 | 8/5/2025 |
1.0.28 | 58 | 8/1/2025 |
1.0.27 | 50 | 8/1/2025 |
1.0.26 | 61 | 8/1/2025 |
1.0.25 | 60 | 8/1/2025 |
1.0.24 | 65 | 8/1/2025 |
1.0.23 | 111 | 7/31/2025 |
1.0.22 | 117 | 7/31/2025 |
1.0.21 | 113 | 7/30/2025 |
1.0.20 | 141 | 7/8/2025 |
1.0.19 | 133 | 7/8/2025 |
1.0.18 | 134 | 7/8/2025 |
1.0.17 | 145 | 6/18/2025 |
1.0.16 | 162 | 5/28/2025 |
1.0.15 | 145 | 5/27/2025 |
1.0.14 | 147 | 5/27/2025 |
1.0.13 | 147 | 5/27/2025 |
1.0.12 | 144 | 5/26/2025 |
1.0.11 | 144 | 5/26/2025 |
1.0.10 | 86 | 5/23/2025 |
1.0.9 | 93 | 5/23/2025 |
1.0.8 | 143 | 5/22/2025 |
1.0.7 | 160 | 5/21/2025 |
1.0.6 | 143 | 5/21/2025 |
1.0.5 | 147 | 5/21/2025 |
1.0.4 | 142 | 5/21/2025 |
1.0.1 | 145 | 5/20/2025 |
1.0.0 | 145 | 5/20/2025 |
First publish. Please do not use for now