Slider

slider — lightweight horizontal carousel

Simple carousel with prev/next arrows. Native CSS scroll-snap under the hood — small, fast, no autoplay, no bullets, no infinite loop. For the fancier use case (autoplay, bullets, breakpoints) pick glide-slider instead.

Use it for product strips on category / homepage, reference gallery, related items section — anywhere users want to peek at a list and scroll through it themselves.

Install

npx czg-ui add slider

@import 'components/slider'; to app.scss, import './components/slider'; to app.js.

Requires base.

Parameters

ParamTypeDefaultNotes
idstringUnique id (required for JS bindings)
itemsiterableCollection passed one-by-one to itemTemplate
itemsPerViewint3Visible items at the largest breakpoint (1 \2 \3 \4)
itemTemplatestring\nullPath to a Latte template that renders one item

Responsive behavior

Built-in breakpoints (no config needed):

WidthItems per view
≥ desktopas configured (default 3)
640–960px2 (capped from 3 or 4)
< 640px1

Set via the data-items-per-view attribute the wrapper renders.

Usage

{var $products = $eshopRepository->getRelated($product->id, 6)}

{include /app/components/Slider/slider.latte,
    id           => 'related',
    items        => $products,
    itemsPerView => 4,
    itemTemplate => '/app/components/Eshop/product-card.latte'
}

The card template receives $item:

{* product-card.latte *}
<a href="{$item->url}" class="product-card">
    <img src="{$item->image}" alt="{$item->title}">
    <h3>{$item->title}</h3>
</a>

When NOT to use

  • Hero with single rotating banner — pick glide-slider (autoplay)
  • Pagination over a large dataset — slider is for ~3–10 items, not

100; use real pagination + grid instead

Live preview

ui.czechgroup.cz/component/slider

Další kategorie