Component
Carousel
A draggable slider built on Embla. Show one or several items per view, run horizontal or vertical, loop, autoplay, and drive it with previous, next, and dot controls.
Basic
1
2
3
4
5
Slide 1 / 5
import { ChangeDetectionStrategy, Component, signal } from '@angular/core';
import { HbCarouselImports } from '@herbst/ui';
@Component({
selector: 'hb-demo-carousel-basic',
imports: [HbCarouselImports],
template: `
<div class="flex flex-col gap-2">
<hb-carousel class="block w-96 max-w-full" hbSize="lg" (hbSelect)="current.set($event)">
<hb-carousel-content>
@for (n of slides; track n) {
<hb-carousel-item>
<div
class="flex h-40 items-center justify-center rounded-md bg-muted font-display text-4xl"
>
{{ n }}
</div>
</hb-carousel-item>
}
</hb-carousel-content>
<hb-carousel-previous />
<hb-carousel-next />
<hb-carousel-dots />
</hb-carousel>
<p class="font-mono text-[12px] text-muted-foreground">
Slide {{ current() + 1 }} / {{ slides.length }}
</p>
</div>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class HbDemoCarouselBasicComponent {
protected readonly slides = [1, 2, 3, 4, 5];
protected readonly current = signal(0);
}
Multiple per view & loop
1
2
3
4
5
6
7
8
Autoplay
1
2
3
4
Vertical & free drag
1
2
3
4
5
6
7
8
API reference
hb-carousel
| Property | Description | Type | Default |
|---|---|---|---|
| [hbOrientation] | Scroll axis of the carousel. | 'horizontal' | 'vertical' | 'horizontal' |
| [hbAlign] | Where the active slide snaps within the viewport. | 'start' | 'center' | 'end' | 'start' |
| [hbLoop] | Wrap around from the last slide to the first. | boolean | false |
| [hbDragFree] | Free-scrolling drag without snapping to slides. | boolean | false |
| [hbSpacing] | Gap between slides in pixels. | number | 16 |
| [hbSize] | Size of the previous/next buttons and dots. | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'md' |
| [hbAutoplay] | Advance slides automatically. | boolean | false |
| [hbDelay] | Autoplay interval in milliseconds. | number | 4000 |
| (hbSelect) | Emits the index of the newly active slide. | number | — |
Parts
| Property | Description | Type | Default |
|---|---|---|---|
| hb-carousel-content / hb-carousel-item | Track and its slides; item basis (e.g. basis-1/3) sets how many show. | slot | — |
| hb-carousel-previous / hb-carousel-next | Buttons that step one slide back or forward. | element | — |
| hb-carousel-dots | Pagination dots reflecting the active slide. | element | — |