Skip to content

Carousels

The carousel directive turns a list of images or content blocks into a responsive Slick carousel. It accepts Markdown images, list items, raw HTML <div> elements and FrontMark ::: container blocks.

FormSyntaxUsage
Carousel::: carousel { ... }Component wrapper.
Image slide![Alt](/image.jpg)One direct image per slide.
List- ![Alt](/image.jpg)One list item per slide.
Container slide::: container { ... }Rich FrontMark content.
HTML slide<div>...</div>Arbitrary static HTML.
Multi-block slideSeparate slides with ---Group a heading, text and media.

The default configuration matches the standard FrontMark slideshow:

{
  autoplay: true,
  autoplaySpeed: 4000,
  pauseOnHover: true,
  pauseOnFocus: true,
  dots: true,
  slidesToShow: 1,
  arrows: false,
  lazyLoad: "ondemand",
  focusOnSelect: true
}

Each direct image is a slide. Camel case and kebab case are both accepted for option names.

::: carousel { autoplay=true autoplaySpeed=4000 pauseOnHover=true pauseOnFocus=true dots=true slidesToShow=1 arrows=false lazyLoad=ondemand focusOnSelect=true aria-label="FrontMark gallery" aspect-ratio="16/7" image-fit=cover }

![FrontMark visual](https://dummyimage.com/1200x525/062b42/e8f7fa&text=FrontMark)

![Markdown visual](https://dummyimage.com/1200x525/0d6f84/f8fafc&text=Markdown)

![Astro visual](https://dummyimage.com/1200x525/114c64/f8fafc&text=Astro)

:::

When the directive contains one Markdown list, every list item becomes a slide. An item may contain an image plus a caption or other Markdown.

::: carousel { autoplay=false arrows=true dots=true lazyLoad=progressive aria-label="Photo list" }

- ![First landscape](https://dummyimage.com/1200x525/001522/f8fafc&text=Landscape+1)
- ![Second landscape](https://dummyimage.com/1200x525/073047/f8fafc&text=Landscape+2)
- ![Third landscape](https://dummyimage.com/1200x525/246078/f8fafc&text=Landscape+3)

:::

Direct ::: container children are preserved as complete slides. This is useful for calls to action, feature cards and mixed Markdown content.

::: carousel { autoplay=false adaptiveHeight=true arrows=true dots=true aria-label="Feature cards" }

::: container { predef=rounded-callout align=center pad=2rem }
## Portable Markdown

Keep the source readable and let FrontMark handle presentation.
:::

::: container { predef=soft-bordered align=center pad=2rem }
## Rich components

Add images, links, icons and other supported Markdown blocks.
:::

::: container { predef=cta-halo align=center pad=2rem }
## Responsive by default

Swipe on touch screens or use the optional arrows and dots.
:::

:::

A complete raw HTML <div> is treated as one slide. Keep a blank line between sibling elements and before the closing ::: marker.

::: carousel { autoplay=false arrows=true dots=true adaptiveHeight=true aria-label="HTML cards" }

<div style="min-height: 13rem; padding: 2rem; border-radius: .75rem; background: #073047; color: #f8fafc;">
  <h3>HTML slide</h3>
  <p>Any static HTML can live inside a carousel slide.</p>
</div>

<div style="min-height: 13rem; padding: 2rem; border-radius: .75rem; background: #114c64; color: #f8fafc;">
  <h3>Second slide</h3>
  <p>Use semantic HTML and keep interactive controls keyboard accessible.</p>
</div>

:::

By default, each top-level Markdown block is a slide. Add a thematic separator (---) when one slide must contain several blocks.

::: carousel { autoplay=false arrows=true adaptiveHeight=true }

## First topic

A paragraph and its heading stay together because the next slide starts at `---`.

---

## Second topic

This heading and paragraph form the second slide.

:::

Multiple slides and responsive breakpoints

Section titled “Multiple slides and responsive breakpoints”

Use a JSON array in responsive for breakpoint-specific settings. Slick uses desktop-first breakpoints unless mobileFirst=true.

::: carousel { autoplay=false arrows=true dots=true slidesToShow=3 slidesToScroll=1 gap=1rem responsive='[{"breakpoint": 900, "settings": {"slidesToShow": 2}}, {"breakpoint": 620, "settings": {"slidesToShow": 1, "arrows": false}}]' }

<div style="padding: 3rem 1rem; text-align: center; background: #062b42; color: white;">One</div>

<div style="padding: 3rem 1rem; text-align: center; background: #0d6f84; color: white;">Two</div>

<div style="padding: 3rem 1rem; text-align: center; background: #114c64; color: white;">Three</div>

<div style="padding: 3rem 1rem; text-align: center; background: #246078; color: white;">Four</div>

:::

Option names may use Slick camel case (slidesToShow) or Markdown-friendly kebab case (slides-to-show). Values are validated before being included in the generated page.

OptionTypeFrontMark defaultPurpose
autoplayBooleantrueAdvance slides automatically.
autoplaySpeedMilliseconds4000Delay between automatic changes.
pauseOnHoverBooleantruePause while the pointer is over the carousel.
pauseOnFocusBooleantruePause while a child has keyboard focus.
dotsBooleantrueShow paging indicators.
arrowsBooleanfalseShow previous and next buttons.
slidesToShowInteger1Number of visible slides.
slidesToScrollInteger1Number of slides moved at once.
focusOnSelectBooleantrueMove to a selected slide.
lazyLoadondemand, progressive, anticipated, falseondemandDefer image loading.
adaptiveHeightBooleanfalseFollow the current slide height.
infiniteBooleantrueLoop back to the first slide.
fadeBooleanfalseCross-fade instead of sliding; use with one visible slide.
speedMilliseconds500Transition duration.
centerModeBooleanfalseCenter the current slide with adjacent previews.
centerPaddingCSS length50pxSide padding used by center mode.
initialSlideInteger0Zero-based initial slide.
draggable, swipe, touchMoveBooleantruePointer and touch interaction.
swipeToSlideBooleanfalseSwipe directly to a slide regardless of slidesToScroll.
vertical, verticalSwipingBooleanfalseVertical layout and gestures.
variableWidthBooleanfalsePreserve individual slide widths.
rows, slidesPerRowInteger1Grid mode.
rtlBooleanfalseRight-to-left movement.
mobileFirstBooleanfalseInterpret responsive breakpoints from small to large.
responsiveJSON arraynoneBreakpoint-specific settings or "unslick".
accessibilityBooleantrueKeyboard navigation and ARIA state.

Component-only presentation attributes are also available:

AttributeExamplePurpose
aria-labelaria-label="Project gallery"Accessible carousel name.
heightheight=28remFixed slide and image height.
aspect-ratioaspect-ratio="16/9"Responsive image ratio.
image-fitcover, containImage object fitting.
gapgap=1remSpace between visible slides.
#id / .class#gallery .wideCustom hook on the component wrapper.

Carousel controls automatically inherit the active FrontMark theme. Their surface uses the theme panel color, while borders and dots use its accent color and arrow icons use its text color. This also follows live light/dark changes in switchable themes.

Add a custom class to override only the controls for one carousel:

::: carousel .brand-gallery { arrows=true dots=true }
...
:::
.brand-gallery {
  --mkdocs-carousel-control-background: rgb(255 255 255 / 92%);
  --mkdocs-carousel-control-hover-background: #f1f5f9;
  --mkdocs-carousel-control-border: #0f766e;
  --mkdocs-carousel-control-color: #134e4a;
  --mkdocs-carousel-control-shadow: 0 0.45rem 1.4rem rgb(15 23 42 / 20%);
}

The arrow buttons remain vertically centered on the slide viewport whether dots are enabled or not. An isolated foreground layer also keeps them above positioned HTML and FrontMark containers inside a slide. Focus outlines, reduced-motion preferences and forced-color mode are handled automatically.