Carousel
Swipeable slides with arrows, dots, looping and auto-play.
Installation
bash
shellui-native add carousel
Platforms: MAUI · Avalonia. Also installs icon.
Usage
Basic
ShellUI
Components for Blazor.
ShellUI Native
Components for MAUI and Avalonia.
ShellIcons
Lucide icons for every .NET UI.
<ui:Carousel AspectRatio="2.4" PositionChanged="OnSlideChanged">
<Grid BackgroundColor="{DynamicResource ShellUIMuted}">
<Label Text="ShellUI" HorizontalOptions="Center" VerticalOptions="Center" />
</Grid>
<Grid BackgroundColor="{DynamicResource ShellUIMuted}">
<Label Text="ShellUI Native" HorizontalOptions="Center" VerticalOptions="Center" />
</Grid>
<Grid BackgroundColor="{DynamicResource ShellUIMuted}">
<Label Text="ShellIcons" HorizontalOptions="Center" VerticalOptions="Center" />
</Grid>
</ui:Carousel><ui:Carousel AspectRatio="2.4" PositionChanged="OnSlideChanged">
<Panel Background="{DynamicResource ShellUIMutedBrush}">
<TextBlock Text="ShellUI" HorizontalAlignment="Center" VerticalAlignment="Center" />
</Panel>
<Panel Background="{DynamicResource ShellUIMutedBrush}">
<TextBlock Text="ShellUI Native" HorizontalAlignment="Center" VerticalAlignment="Center" />
</Panel>
<Panel Background="{DynamicResource ShellUIMutedBrush}">
<TextBlock Text="ShellIcons" HorizontalAlignment="Center" VerticalAlignment="Center" />
</Panel>
</ui:Carousel>Not available on yet
MAUI and Avalonia
- On Avalonia you drag slides with the mouse as well as with touch.
- The Avalonia arrows are tab stops, and Left / Right change the slide while one has focus.
- With
AspectRatio="0", give the carousel a height:HeightRequeston MAUI,Heighton Avalonia.
API
XAML children go to Slides.
| Property | Type | Default | Description |
|---|---|---|---|
Position |
int |
0 |
Index of the current slide. Two-way bindable. |
Loop |
bool |
true |
At the last slide, Next wraps to the first (and Previous the other way). |
ShowArrows |
bool |
true |
Shows the previous / next buttons. |
ShowDots |
bool |
true |
Shows the position dots. |
AutoPlay |
bool |
false |
Advances slides on a timer. |
AutoPlayInterval |
int |
3000 |
Milliseconds between slides while AutoPlay is on. |
AspectRatio |
double |
16 : 9 (1.7778) |
Width / height of the frame. 0 turns it off: set HeightRequest on the carousel instead. |
| Event | Arguments | Description |
|---|---|---|
PositionChanged |
int |
User input only (arrows, dots, swipes, keys): auto-play, Next / Previous and setting Position from code don't raise it. |
| Method | Description |
|---|---|
Next() |
Shows the next slide. |
Previous() |
Shows the previous slide. |