[ Installation ]

npx wally-ui add carousel

[ Preview ]

[ Import ]

import { Carousel } from './components/wally-ui/carousel/carousel';
@Component({
  selector: 'app-example',
  imports: [Carousel],
  templateUrl: './example.html',
  styleUrl: './example.css'
})

[ Basic Usage ]

Simple carousel setup - just wrap your content elements. No configuration required.

<wally-carousel>
  <div>Item 1</div>
  <div>Item 2</div>
</wally-carousel>
<wally-carousel [isNavigationIndicator]="true">
  <div>Item 1</div>
  <div>Item 2</div>
</wally-carousel>

[ Advanced Examples ]

Custom Content

<wally-carousel>
  <div class="w-full h-full bg-gradient-to-r from-blue-500 to-purple-600 text-white flex flex-col items-center justify-center p-6">
    <h3 class="text-xl font-bold mb-2">Feature 1</h3>
    <p class="text-center text-sm">Custom slide with rich content</p>
  </div>
  <div class="w-full h-full bg-gradient-to-r from-green-500 to-blue-500 text-white flex flex-col items-center justify-center p-6">
    <h3 class="text-xl font-bold mb-2">Feature 2</h3>
    <p class="text-center text-sm">Another slide with different styling</p>
  </div>
</wally-carousel>

[ Responsive Design ]

The carousel is 100% responsive and adapts to any container size. Simply set the parent container dimensions and the carousel will fill it completely.

<!-- Different sizes for different use cases -->

<!-- Hero carousel - full width, tall -->
<div class="w-full h-96">
  <wally-carousel>
    <div>Hero slide 1</div>
    <div>Hero slide 2</div>
  </wally-carousel>
</div>

<!-- Product gallery - square aspect ratio -->
<div class="w-full aspect-square max-w-md">
  <wally-carousel>
    <div>Product image 1</div>
    <div>Product image 2</div>
  </wally-carousel>
</div>

<!-- Mobile testimonials - compact -->
<div class="w-full h-48 sm:h-64">
  <wally-carousel>
    <div>Testimonial 1</div>
    <div>Testimonial 2</div>
  </wally-carousel>
</div>

[ Accessibility ]

The carousel is built with comprehensive accessibility features and follows WCAG guidelines for inclusive design.

ARIA Attributes

role="region"

Identifies the carousel as a landmark region

aria-label="Carousel"

Provides accessible name for screen readers

tabindex="0"

Makes carousel keyboard focusable

aria-label="Navigate to slide X"

Descriptive labels for navigation indicators

Keyboard Navigation Example

Click the carousel below to focus it, then use keyboard arrows to navigate:

[ Properties ]

The carousel component accepts one optional input property and automatically manages its internal state.

Input Properties

isNavigationIndicator: InputSignal<boolean> = input<boolean>(false);

Controls whether navigation indicators (dots) are displayed below the carousel.

Read-only Properties

totalItemsCount: number (read-only);

Automatically detected number of child elements in the carousel

currentVisibleItemIndex: number (read-only);

Zero-based index of the currently visible slide

navigationIndicatorsArray: any[] (read-only);

Auto-generated array used for rendering navigation indicators

[ API Methods ]

Public methods available for programmatic control of the carousel. Access these methods through a template reference or ViewChild.

MethodParametersReturnDescription
Navigation Methods
navigateToNextItem()NonevoidNavigate to the next slide with circular navigation
navigateToPreviousItem()NonevoidNavigate to the previous slide with circular navigation
navigateToSpecificItem()index: numbervoidJump directly to a specific slide by index (0-based)
Calculation Methods
calculateNextItemIndex()current: numbernumberCalculate the next index using circular buffer algorithm
calculatePreviousItemIndex()current: numbernumberCalculate the previous index using circular buffer algorithm
Positioning Methods
updateItemElementPosition()element: HTMLElement
index: number
voidUpdate position of a specific carousel item element
updateAllItemElementPositions()NonevoidUpdate positions of all carousel item elements

[ Keyboard Navigation ]

When the carousel has focus, users can navigate using these keyboard shortcuts.

// Keyboard navigation (when carousel is focused)
ArrowLeft  → Previous slide
ArrowRight → Next slide
Home       → First slide
End        → Last slide

[ Touch & Mouse Gestures ]

Interactive gestures supported on both mobile and desktop devices.

// Touch and mouse gestures
Swipe Left  → Next slide
Swipe Right → Previous slide
Click Dots  → Jump to specific slide
Drag        → Same as swipe (desktop)