---json
{
"aliases": [
{ "path": ":release:beta:carrousel" }
],
"description": "The carrousel component permits to layout and to scroll components horizontally.",
"page_id": "jp4qhbhgdeg3pxkzvzry3",
"title": "How to create a carrousel layout"
}
---
====== ComboStrap - Carrousel Layout ======
===== About =====
A carrousel is a layout component where the user can cycle through elements in a horizontal way.
To cycle through the elements, you can use:
* on a mobile, the swipe hand gesture
* on a desktop, the mouse or the arrow and bullet control elements.
Because a carrousel is also known as a slideshow, the elements of a carrousel are generally called ''slides''.
===== Example =====
==== Image Gallery ====
This example shows you a carrousel of [[docs:content:image|image]] known also as a image gallery.
* The cards:
{{ :woman-yoga-sunset.jpg?0x600 |}}
{{ :page_speed_performance.png?0x600 |}}
{{ :undraw_content_creator.svg?0x600 |}}
* The output:
==== Carrousel dynamically created with the iterator ====
With the [[docs:templating:iterator|template iterator]], you can create dynamically the children that you want to show.
Example with all pages that are in the layout path.
* The iterator with the data node that uses the [[docs:templating:sql|page sql]] to select the pages
select where path like "%layout%" order by title asc limit 10
The pages talking about layout in ComboStrap
== $title ==
${date_modified | format("eeee dd-MM KK:mm")}
${description" | head(200,"...")} [[$path| ]]
* The output:
\\
\\
==== Minimum Elements Count ====
If the number of elements is not enough to feel the screen, the default behavior of the carrousel is to repeat them.
The ''elements-min'' attribute permits to disable this feature and to replace the carrousel by a [[docs:layout:component:grid|grid]] if the minimum element count is not met. By default, the value is ''3''.
This feature is most used with an [[docs:templating:iterator|iterator]] where the number of element is not known in advance but for the purpose if this demonstration we are using 2 fix [[docs:block:card|cards]].
{{:logo.svg?ratio=21:9|}}
=== First Card ===
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
{{:logo.svg?ratio=21:9|}}
=== Second Card ===
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
* The output is a centered [[docs:layout:component:grid|grid]].
===== Syntax =====
where:
* ''element-width'' is the minimum [[docs:styling:dimension|width]] of an element on the screen. By default, this is 100% (meaning that there is only one element, ie a gallery)
* ''elements-min'' is the minimum of elements needed to show a carrousel. By default: ''3''. If this threshold is not met, a [[docs:layout:component:grid|grid]] is instead used.
* ''control'' manages the control elements. If ''none'', no arrow buttons or bullets are shown.
\\
\\
= Implicit difference between the gallery mode and other carrousels =
A gallery for Combostrap is a carrousel that shows only one element at a time. This is the default mode (ie when the ''element-width'' attribute is unset).
* In this mode:
* the arrow buttons are the only controls visible on mobile
* there is always one element in view
* In other mode (when there is more than one element on the screen)
* there is no control visible on mobile
* the number of elements shown is a plain number and a half (to show that this is serie of element)
===== Support =====
==== Lazy Loading ====
[[docs:performance:lazy|Lazy loading]] works on modern browser where the [[https://caniuse.com/?search=loading|loading attribute is supported]].