Carousels without Swiper: slides on a track, and the LedgerUI.Carousel hook for arrows,
pagination, autoplay, keyboard, swipe and effects.
<.carousel id="gallery" navigation slides={3}>
<.carousel_slide><img class="h-full w-full object-cover" src="/a.jpg" alt="" /></.carousel_slide>
<.carousel_slide>...</.carousel_slide>
<.carousel_slide>...</.carousel_slide>
</.carousel>
<.carousel id="promo" pagination="bullets" slides={3} autoplay={2000} loop>...</.carousel>
<.carousel id="flip" effect="flip" navigation>...</.carousel>effect is slide (the scrolling track), fade, flip, cube, cards, coverflow or
creative. pagination is bullets, fraction, progress or scrollbar; it is rendered
on the server, so give the number of slides (or one :thumb slot per slide). :thumb slots
draw a row of thumbnails under the track that pick the slide.
The server's slide is index; the person moves freely in the browser, and their slide survives
patches. on_change (an event name or %JS{}) runs when the slide changes; an event name is
pushed with %{"id" => id, "index" => index} to target. From the server,
push_event(socket, "ledger:carousel", %{id: "gallery", index: 2}) moves it.
The component renders the track and, as its siblings, the pagination and the thumbnails.
The bullets are <i role="button" tabindex="0" aria-label=...> rendered by the server; the hook only moves aria-current and the slides' aria-hidden.
Configuration that is not the default travels in data-* attributes of the track's root, which
carries phx-hook="LedgerUI.Carousel".
Summary
Functions
Attributes
id(:string) (required)index(:integer) - The active slide, zero-based. Defaults to0.effect(:string) - Defaults to"slide". Must be one of"slide","fade","flip","cube","cards","coverflow", or"creative".direction(:string) - Defaults to"horizontal". Must be one of"horizontal", or"vertical".navigation(:any) - The previous and next arrows. Defaults tofalse. Must be one oftrue,false,"inside", or"outside".pagination(:string) - Defaults tonil.Must be one ofnil,"bullets","fraction","progress", or"scrollbar".slides(:integer) - How many slides there are, for the pagination (the:thumbcount when omitted). Defaults tonil.autoplay(:integer) - Milliseconds between slides; pauses on hover. Defaults tonil.loop(:boolean) - Defaults tofalse.gap(:integer) - Pixels between slides. Defaults tonil.zoom(:integer) - Double-click zoom ratio. Defaults tonil.on_change(:any) - Defaults tonil.target(:any) - Defaults tonil.prev_label(:string) - Defaults to"Previous slide".next_label(:string) - Defaults to"Next slide".bullet_label(:string) - Defaults to"Go to slide".label(:string) - Defaults tonil.variant(:string) - Defaults to"canvas". Must be one of"canvas", or"classic".thumb_label(:string) - Defaults to"Show slide".class(:any) - Defaults tonil.- Global attributes are accepted.
Slots
background- Behind the track, for a parallax background.inner_block(required)thumb- A thumbnail per slide, in order.
Attributes
class(:any) - Defaults tonil.- Global attributes are accepted.
Slots
inner_block(required)