Carousel
A tile-based horizontal scroll carousel with CSS scroll-snap, prev/next navigation buttons,
and optional dot indicators. Each click of Next/Prev snaps to the adjacent tile.
Supports server-rendered tiles (PHP array) or client-side loading from a remote JSON endpoint.
Dot placement defaults to 'below'. Use ->dots('above')
or ->dots('none') to change or remove them.
Default — dots below
Server-rendered tiles, dot indicators positioned below the carousel.
Dots above
Navigate with dots placed above the carousel. Use a wider tile width.
No dots
Carousel with only prev/next buttons — no dot indicators.
Single tile — buttons / dots hidden
When only one tile exists, navigation buttons and dots are automatically hidden.
Tiles without images
When no imageUrl is provided, a placeholder icon is shown.
Remote datasource (client-side)
Pass ->remoteUrl() instead of ->tiles() to load tiles
client-side on page load. The endpoint should return
{ "tiles": [ {title, href, imageUrl, caption}, … ] }.
A perPage query param is appended when set via ->perPage().
/demo/carouselData on page load.
Tiles with chips
Pass an optional chip (and optional chipVariant) per tile to show a coloured
chip label overlaid in the top-right corner of the tile image.
Variants: primary, success, warning, danger,
purple, secondary (default), info.
JS API
Control the carousel programmatically using m.carousel(id).
PHP PHP Methods (Fluent)
| Method / Property | Parameters | Description |
|---|---|---|
$m->carousel($id) | string | Create a Carousel component. |
->tile($title, $href, $imageUrl, $caption, $chip, $chipVariant) | string, string, ?string, ?string, ?string, string | Add a single tile. imageUrl, caption, and chip are optional. chipVariant defaults to 'secondary'. |
->tiles($tiles) | array | Add multiple tiles at once. Each element: {title, href, imageUrl?, caption?, chip?, chipVariant?}. |
->remoteUrl($url) | string | Client-side remote datasource URL. Response: {"tiles":[…]}. Each tile object may include chip and chipVariant. |
->perPage($n) | int | Tiles per remote fetch (appended as ?perPage=N). Default: 0 (load all). |
->dots($placement) | string | Dot indicator placement. 'below' (default), 'above', or 'none'. |
->tileWidth($css) | string | CSS width of each tile. Default: '160px'. Accepts any CSS length. |
->tileGap($px) | int | Gap between tiles in pixels. Default: 12. |
JS JS Methods
| Method / Property | Parameters | Description |
|---|---|---|
m.carousel(id) | string|Element | Get the Carousel API for the given element ID or DOM element. |
c.goTo(idx) | number | Navigate to tile at zero-based idx. |
c.next() | | Navigate to the next tile. |
c.prev() | | Navigate to the previous tile. |
c.current() | | Returns the current tile index (0-based). |
c.count() | | Returns the total number of tiles. |
c.reload(url?, perPage?) | | Reload tiles from a remote URL. Defaults to configured remoteUrl/perPage. |
EVENT Events
| Event Name | Detail | Description |
|---|---|---|
m:carousel:change | { index: number } | Fired on the carousel element when the active tile changes. |
m:carousel:loaded | { count: number } | Fired on the carousel element after remote tiles have loaded. |