Skip to content

Type to search the docs, API, and blog.

↑↓ navigate↵ openesc close
  • Zazz 0.14 alpha

    API

    Carousel

    A native scroll-snap slideshow with arrows, dots, thumbnails, loop, and autoplay.

    Installation

    Source
    pnpm dlx zazz-ui add carousel
    npx zazz-ui add carousel
    yarn dlx zazz-ui add carousel
    bunx zazz-ui add carousel

    Run zazz-ui init first if the project has no zazz/ folder yet.

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Paint the right theme (background, form controls, scrollbars) before CSS loads -->
    <meta name="color-scheme" content="light dark">
    <!-- Zazz styles: base layers, then carousel in cascade order -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_layers.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_variables.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_shadows.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_breakpoints.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_reset.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_typography.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_view-transitions.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/primitives/carousel/carousel.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-sm.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-md.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-lg.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-xl.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-2xl.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-disabled.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-active.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-focus-visible.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-focus-within.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-hover.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-checked.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-current.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-open.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-stuck.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-starting.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-sm.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-md.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-lg.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-xl.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-2xl.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-disabled.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-active.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-focus-visible.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-focus-within.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-hover.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-checked.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-current.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-open.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-stuck.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-starting.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-flow.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-grid.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-spacing.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-margin.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-sizing.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-typography.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-color.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-effects.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-box.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-pseudo.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_defaults.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-sr.css">
    <!-- Import map: bare specifiers in Zazz scripts resolve to pinned, SRI-checked files -->
    <script type="importmap">
    {
      "imports": {
        "signal-polyfill": "https://cdn.jsdelivr.net/npm/signal-polyfill@0.2.2/dist/index.js"
      },
      "integrity": {
        "https://cdn.jsdelivr.net/npm/signal-polyfill@0.2.2/dist/index.js": "sha384-0OqM7OXGT6Oz1z98u/geiFn/FUyz4iWexkXHCvbIGXRRDXl6bp6IKc0j78AQ6DEK"
      }
    }
    </script>
    <!-- Polyfill: Interest Invokers (interestfor) — native in Chromium only -->
    <script type="module" src="https://cdn.jsdelivr.net/npm/invokers@2.2.2/dist/esm/production/interest.js" integrity="sha384-hR2BVNtsS7fIIMwOm+f7MY0JZfuByGhQQfevCBB6evFATKzBsTw0JzH/RxD94z2T" crossorigin="anonymous"></script>
    <!-- Zazz behavior: side-effect modules by tag; the rest via module imports -->
    <script type="module" src="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/dialog-lifecycle.js"></script>
    <script type="module" src="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/gesture.js"></script>
    <script type="module" src="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/carousel-scroll.js"></script>
    <script type="module" src="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/carousel.js"></script>
    <script type="module" src="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/primitives/carousel/carousel.js"></script>
    <!-- Theme: apply the persisted (or preferred) scheme before first paint -->
    <script>
      (() => {
        try {
          // A stored choice pins the scheme with data-theme; with no choice the
          // page follows the system scheme.
          const storedTheme = localStorage.getItem("theme");
          if (storedTheme === "dark" || storedTheme === "light") {
            document.documentElement.dataset.theme = storedTheme;
          }
        } catch {
          /* no storage access: follow the system scheme */
        }
      })();
    </script>

    A <head> that loads the base layers and carousel from jsDelivr, pinned to 0.14.2. To load the whole kit in two requests, see the CDN install.

    Examples

    <ui-carousel>
      <div
        style="
          --display: flex;
          --flex-wrap: wrap;
          --items: end;
          --justify: space-between;
          --pb: 11;
          --gap: 6;
        "
      >
        <h2
          style="
            --font-size: var(--font-size-h5);
            --font-weight: heading;
            --font-family: var(--font-family-heading);
            --leading: var(--leading-h5);
          "
        >
          Featured Articles
        </h2>
        <div
          style="
            --display: flex;
            --display--md: none;
            --gap: 2;
          "
        >
          <button
            type="button"
            data-ui="button"
            data-button-size="icon"
            data-button-variant="muted"
            data-carousel-slot="prev"
          >
            <svg
              xmlns="http://www.w3.org/2000/svg"
              viewBox="0 0 256 256"
              aria-hidden="true"
              style="--size: 4"
            >
              <rect width="256" height="256" fill="none" />
              <polyline
                points="160 208 80 128 160 48"
                fill="none"
                stroke="currentColor"
                stroke-linecap="round"
                stroke-linejoin="round"
                stroke-width="14"
              />
            </svg>
          </button>
          <button
            type="button"
            data-ui="button"
            data-button-size="icon"
            data-button-variant="muted"
            data-carousel-slot="next"
          >
            <svg
              xmlns="http://www.w3.org/2000/svg"
              viewBox="0 0 256 256"
              aria-hidden="true"
              style="--size: 4"
            >
              <rect width="256" height="256" fill="none" />
              <polyline
                points="96 48 176 128 96 208"
                fill="none"
                stroke="currentColor"
                stroke-linecap="round"
                stroke-linejoin="round"
                stroke-width="14"
              />
            </svg>
          </button>
        </div>
      </div>
    
      <div data-carousel-slot="viewport" style="--overflow: visible">
        <div data-carousel-slot="container" style="--ml: -6">
          <a
            data-carousel-slot="slide"
            href="#"
            style="
              --basis: 100%;
              --basis--sm: 50%;
              --basis--md: 33.333%;
              --basis--lg: 25%;
              --cursor: pointer;
            "
          >
            <div style="--pl: 6">
              <div
                style="
                  --display: grid;
                  --gap: 4;
                  --text: var(--color-card-foreground);
                  --bg: var(--color-card);
                  --border: 1;
                  --radius: 2.5;
                  --overflow: clip;
                "
              >
                <figure
                  style="
                    --aspect: 3 / 2;
                    --radius-t: 2.5;
                    --overflow: clip;
                  "
                >
                  <img
                    width="300"
                    height="200"
                    loading="lazy"
                    src="https://images.unsplash.com/photo-1500382017468-9049fed747ef?auto=format&fit=crop&w=300&h=200&q=60"
                    alt="Zebras grazing at dawn on the savanna"
                    style="
                      --size: 100%;
                      --opacity: 1;
                      --opacity--hover: 0.75;
                      --scale: 1;
                      --scale--hover: 1.02;
                      --transition: var(--default-transition);
                      --object-fit: cover;
                    "
                  />
                </figure>
                <div
                  style="
                    --display: grid;
                    --px: 4;
                    --pb: 4;
                    --gap: 4;
                  "
                >
                  <header
                    style="
                      --display: grid;
                      --gap: 2;
                    "
                  >
                    <div
                      style="
                        --display: flex;
                        --items: center;
                        --gap: 2;
                      "
                    >
                      <span data-ui="badge" data-badge-variant="muted">Field notes</span>
                    </div>
                    <hgroup
                      style="
                        --display: grid;
                        --gap: 2;
                      "
                    >
                      <h3
                        style="
                          --font-size: var(--font-size-lg);
                          --font-family: var(--font-family-heading);
                          --leading: var(--leading-lg);
                          --tracking: var(--tracking-lg);
                          --line-clamp: 1;
                        "
                      >
                        How quickly zebras jump
                      </h3>
                      <p
                        style="
                          --font-size: var(--font-size-sm);
                          --leading: var(--leading-sm);
                          --tracking: var(--tracking-sm);
                          --line-clamp: 2;
                          --text: var(--color-muted-foreground);
                        "
                      >
                        Striped coats and sudden bursts of speed help herds evade predators when the
                        grasslands go quiet at dusk.
                      </p>
                    </hgroup>
                  </header>
                  <footer
                    style="
                      --display: grid;
                      --justify: end;
                      --pt: 4;
                      --pb: 2;
                      --gap: 4;
                      --border-t: 1;
                    "
                  >
                    <div data-ui="button" data-button-variant="link">
                      Read article
                      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
                        <rect width="256" height="256" fill="none" />
                        <line
                          x1="40"
                          y1="128"
                          x2="216"
                          y2="128"
                          fill="none"
                          stroke="currentColor"
                          stroke-linecap="round"
                          stroke-linejoin="round"
                          stroke-width="16"
                        />
                        <polyline
                          points="144 56 216 128 144 200"
                          fill="none"
                          stroke="currentColor"
                          stroke-linecap="round"
                          stroke-linejoin="round"
                          stroke-width="16"
                        />
                      </svg>
                    </div>
                  </footer>
                </div>
              </div>
            </div>
          </a>
    
          <a
            data-carousel-slot="slide"
            href="#"
            style="
              --basis: 100%;
              --basis--sm: 50%;
              --basis--md: 33.333%;
              --basis--lg: 25%;
              --cursor: pointer;
            "
          >
            <div style="--pl: 6">
              <div
                style="
                  --display: grid;
                  --gap: 4;
                  --text: var(--color-card-foreground);
                  --bg: var(--color-card);
                  --border: 1;
                  --radius: 2.5;
                  --overflow: clip;
                "
              >
                <figure
                  style="
                    --aspect: 3 / 2;
                    --radius-t: 2.5;
                    --overflow: clip;
                  "
                >
                  <img
                    width="300"
                    height="200"
                    loading="lazy"
                    src="https://images.unsplash.com/photo-1564760055775-d63b17a55c44?auto=format&fit=crop&w=300&h=200&q=60"
                    alt="A lion resting in tall golden grass"
                    style="
                      --size: 100%;
                      --opacity: 1;
                      --opacity--hover: 0.75;
                      --scale: 1;
                      --scale--hover: 1.02;
                      --transition: var(--default-transition);
                      --object-fit: cover;
                    "
                  />
                </figure>
                <div
                  style="
                    --display: grid;
                    --px: 4;
                    --pb: 4;
                    --gap: 4;
                  "
                >
                  <header
                    style="
                      --display: grid;
                      --gap: 2;
                    "
                  >
                    <div
                      style="
                        --display: flex;
                        --items: center;
                        --gap: 2;
                      "
                    >
                      <span data-ui="badge" data-badge-variant="muted">Wildlife</span>
                    </div>
                    <hgroup
                      style="
                        --display: grid;
                        --gap: 2;
                      "
                    >
                      <h3
                        style="
                          --font-size: var(--font-size-lg);
                          --font-family: var(--font-family-heading);
                          --leading: var(--leading-lg);
                          --tracking: var(--tracking-lg);
                          --line-clamp: 1;
                        "
                      >
                        Lions at golden hour
                      </h3>
                      <p
                        style="
                          --font-size: var(--font-size-sm);
                          --leading: var(--leading-sm);
                          --tracking: var(--tracking-sm);
                          --line-clamp: 2;
                          --text: var(--color-muted-foreground);
                        "
                      >
                        Warm light and long shadows make dawn patrols the best time to photograph big
                        cats on the open plain.
                      </p>
                    </hgroup>
                  </header>
                  <footer
                    style="
                      --display: grid;
                      --justify: end;
                      --pt: 4;
                      --pb: 2;
                      --gap: 4;
                      --border-t: 1;
                    "
                  >
                    <div data-ui="button" data-button-variant="link">
                      View gallery
                      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
                        <rect width="256" height="256" fill="none" />
                        <line
                          x1="40"
                          y1="128"
                          x2="216"
                          y2="128"
                          fill="none"
                          stroke="currentColor"
                          stroke-linecap="round"
                          stroke-linejoin="round"
                          stroke-width="16"
                        />
                        <polyline
                          points="144 56 216 128 144 200"
                          fill="none"
                          stroke="currentColor"
                          stroke-linecap="round"
                          stroke-linejoin="round"
                          stroke-width="16"
                        />
                      </svg>
                    </div>
                  </footer>
                </div>
              </div>
            </div>
          </a>
    
          <a
            data-carousel-slot="slide"
            href="#"
            style="
              --basis: 100%;
              --basis--sm: 50%;
              --basis--md: 33.333%;
              --basis--lg: 25%;
              --cursor: pointer;
            "
          >
            <div style="--pl: 6">
              <div
                style="
                  --display: grid;
                  --gap: 4;
                  --text: var(--color-card-foreground);
                  --bg: var(--color-card);
                  --border: 1;
                  --radius: 2.5;
                  --overflow: clip;
                "
              >
                <figure
                  style="
                    --aspect: 3 / 2;
                    --radius-t: 2.5;
                    --overflow: clip;
                  "
                >
                  <img
                    width="300"
                    height="200"
                    loading="lazy"
                    src="https://images.unsplash.com/photo-1511735111819-9a3f7709049c?auto=format&fit=crop&w=300&h=200&q=60"
                    alt="Elephants crossing a dusty riverbed"
                    style="
                      --size: 100%;
                      --opacity: 1;
                      --opacity--hover: 0.75;
                      --scale: 1;
                      --scale--hover: 1.02;
                      --transition: var(--default-transition);
                      --object-fit: cover;
                    "
                  />
                </figure>
                <div
                  style="
                    --display: grid;
                    --px: 4;
                    --pb: 4;
                    --gap: 4;
                  "
                >
                  <header
                    style="
                      --display: grid;
                      --gap: 2;
                    "
                  >
                    <div
                      style="
                        --display: flex;
                        --items: center;
                        --gap: 2;
                      "
                    >
                      <span data-ui="badge" data-badge-variant="muted">Research</span>
                    </div>
                    <hgroup
                      style="
                        --display: grid;
                        --gap: 2;
                      "
                    >
                      <h3
                        style="
                          --font-size: var(--font-size-lg);
                          --font-family: var(--font-family-heading);
                          --leading: var(--leading-lg);
                          --tracking: var(--tracking-lg);
                          --line-clamp: 1;
                        "
                      >
                        Migration patterns decoded
                      </h3>
                      <p
                        style="
                          --font-size: var(--font-size-sm);
                          --leading: var(--leading-sm);
                          --tracking: var(--tracking-sm);
                          --line-clamp: 2;
                          --text: var(--color-muted-foreground);
                        "
                      >
                        Satellite collars reveal ancient routes herds still follow each dry season
                        across the floodplain.
                      </p>
                    </hgroup>
                  </header>
                  <footer
                    style="
                      --display: grid;
                      --justify: end;
                      --pt: 4;
                      --pb: 2;
                      --gap: 4;
                      --border-t: 1;
                    "
                  >
                    <div data-ui="button" data-button-variant="link">
                      See the data
                      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
                        <rect width="256" height="256" fill="none" />
                        <line
                          x1="40"
                          y1="128"
                          x2="216"
                          y2="128"
                          fill="none"
                          stroke="currentColor"
                          stroke-linecap="round"
                          stroke-linejoin="round"
                          stroke-width="16"
                        />
                        <polyline
                          points="144 56 216 128 144 200"
                          fill="none"
                          stroke="currentColor"
                          stroke-linecap="round"
                          stroke-linejoin="round"
                          stroke-width="16"
                        />
                      </svg>
                    </div>
                  </footer>
                </div>
              </div>
            </div>
          </a>
    
          <a
            data-carousel-slot="slide"
            href="#"
            style="
              --basis: 100%;
              --basis--sm: 50%;
              --basis--md: 33.333%;
              --basis--lg: 25%;
              --cursor: pointer;
            "
          >
            <div style="--pl: 6">
              <div
                style="
                  --display: grid;
                  --gap: 4;
                  --text: var(--color-card-foreground);
                  --bg: var(--color-card);
                  --border: 1;
                  --radius: 2.5;
                  --overflow: clip;
                "
              >
                <figure
                  style="
                    --aspect: 3 / 2;
                    --radius-t: 2.5;
                    --overflow: clip;
                  "
                >
                  <img
                    width="300"
                    height="200"
                    loading="lazy"
                    src="https://images.unsplash.com/photo-1470071459604-3b5ec3a7fe05?auto=format&fit=crop&w=300&h=200&q=60"
                    alt="Misty highland valley at sunrise"
                    style="
                      --size: 100%;
                      --opacity: 1;
                      --opacity--hover: 0.75;
                      --scale: 1;
                      --scale--hover: 1.02;
                      --transition: var(--default-transition);
                      --object-fit: cover;
                    "
                  />
                </figure>
                <div
                  style="
                    --display: grid;
                    --px: 4;
                    --pb: 4;
                    --gap: 4;
                  "
                >
                  <header
                    style="
                      --display: grid;
                      --gap: 2;
                    "
                  >
                    <div
                      style="
                        --display: flex;
                        --items: center;
                        --gap: 2;
                      "
                    >
                      <span data-ui="badge" data-badge-variant="muted">Conservation</span>
                    </div>
                    <hgroup
                      style="
                        --display: grid;
                        --gap: 2;
                      "
                    >
                      <h3
                        style="
                          --font-size: var(--font-size-lg);
                          --font-family: var(--font-family-heading);
                          --leading: var(--leading-lg);
                          --tracking: var(--tracking-lg);
                          --line-clamp: 1;
                        "
                      >
                        Rewilding the highlands
                      </h3>
                      <p
                        style="
                          --font-size: var(--font-size-sm);
                          --leading: var(--leading-sm);
                          --tracking: var(--tracking-sm);
                          --line-clamp: 2;
                          --text: var(--color-muted-foreground);
                        "
                      >
                        Community nurseries are planting native grasses and bringing endemic songbirds
                        back to the ridgeline.
                      </p>
                    </hgroup>
                  </header>
                  <footer
                    style="
                      --display: grid;
                      --justify: end;
                      --pt: 4;
                      --pb: 2;
                      --gap: 4;
                      --border-t: 1;
                    "
                  >
                    <div data-ui="button" data-button-variant="link">
                      Get started
                      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
                        <rect width="256" height="256" fill="none" />
                        <line
                          x1="40"
                          y1="128"
                          x2="216"
                          y2="128"
                          fill="none"
                          stroke="currentColor"
                          stroke-linecap="round"
                          stroke-linejoin="round"
                          stroke-width="16"
                        />
                        <polyline
                          points="144 56 216 128 144 200"
                          fill="none"
                          stroke="currentColor"
                          stroke-linecap="round"
                          stroke-linejoin="round"
                          stroke-width="16"
                        />
                      </svg>
                    </div>
                  </footer>
                </div>
              </div>
            </div>
          </a>
        </div>
      </div>
    </ui-carousel>
    /**
     * carousel.css — scroll-snap carousel (ui-carousel | [data-ui~="carousel"] + data-carousel-slot hooks)
     *
     * @layer      variables, components
     * @requires   _layers.css, _variables.css
     * @uses       data-carousel attributes — the viewport is a native scroll-snap container; base/carousel.js adds mouse drag, loop, controls, and state
     * @uses       data-carousel-state on the viewport — free | gliding | settling | jumping | dragging, written by base/carousel-scroll.js
     * @uses       container-type on viewport — basis-* / @sm:basis-* utils query [data-carousel-slot~="viewport"] width
     * @tokens     --ui-carousel-* (@layer variables)
     * @consumedby lightbox.css
     */
    
    @layer variables {
      :root {
        /* the gap between slides; a --gap utility on the container wins (dual-mode) */
        --ui-carousel-gap: 0px;
        --ui-carousel-slide-basis: calc(100% - var(--ui-carousel-gap));
        --ui-carousel-slide-min-w: 0;
        --ui-carousel-cursor--grabbing: grabbing;
        /* where slides rest (data-carousel-align sets it), and the rubber band's
           return after a mouse drag past an end (0s under reduced motion) */
        --ui-carousel-snap-align: start;
        --ui-carousel-settle-duration: calc(var(--default-transition-duration) * 2);
        --ui-carousel-settle-ease: var(--default-transition-timing-function);
      }
    }
    
    @layer ui.components {
      /* custom elements are inline by default */
      ui-carousel {
        display: block;
      }
    
      :where(ui-carousel, [data-ui~="carousel"]) {
        position: relative;
        isolation: isolate;
      }
    
      /* The viewport is a real scroll container: touch, wheel, trackpad, and keys
         scroll it natively, and it still scrolls with no script at all. RTL needs
         nothing here: the track follows the inherited direction. */
      :where(ui-carousel, [data-ui~="carousel"]) [data-carousel-slot~="viewport"] {
        max-block-size: 100%;
        max-inline-size: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        overscroll-behavior-x: contain;
        scroll-snap-type: var(--_snap-axis, x) mandatory;
        scrollbar-width: none;
      }
    
      /* vertical: data-carousel-axis="y" on the root (data-carousel-thumbs-axis="y"
         on a thumbs slot). Give the viewport a block size; slides fill it by basis. */
      :where(ui-carousel, [data-ui~="carousel"])
        :is(
          [data-carousel-axis="y"]
            [data-carousel-slot~="viewport"]:not([data-carousel-slot~="thumbs"] *),
          [data-carousel-thumbs-axis="y"] [data-carousel-slot~="viewport"]
        ) {
        --_snap-axis: y;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior-x: auto;
        overscroll-behavior-y: contain;
      }
    
      /* free: drag-free (thumb strips by default), no snapping at all.
         gliding: a mouse drag, its release scroll, or auto-scroll; snapping off
         until it lands. settling: a loop rotation's compensating scroll, with the
         axis locked too (iOS Safari otherwise paints the reordered frame before
         the scroll lands). */
      :where(ui-carousel, [data-ui~="carousel"])
        [data-carousel-slot~="viewport"]:is(
          [data-carousel-state~="free"],
          [data-carousel-state~="gliding"],
          [data-carousel-state~="settling"]
        ) {
        scroll-snap-type: none;
        scroll-behavior: auto;
      }
    
      /* jumping: an instant scroll the script makes (start position, dialog start) */
      :where(ui-carousel, [data-ui~="carousel"])
        [data-carousel-slot~="viewport"][data-carousel-state~="jumping"] {
        scroll-behavior: auto;
      }
    
      :where(ui-carousel, [data-ui~="carousel"])
        [data-carousel-slot~="viewport"][data-carousel-state~="settling"] {
        overflow: hidden;
      }
    
      /* a mouse drag would otherwise select the slides' text before the slop */
      :where(ui-carousel, [data-ui~="carousel"]):not([data-carousel-draggable="false"])
        [data-carousel-slot~="viewport"] {
        user-select: none;
      }
    
      /* The pointer is captured for the whole drag, so this one rule keeps the
         grabbing cursor wherever the pointer goes; no page-wide flag. */
      :where(ui-carousel, [data-ui~="carousel"])
        [data-carousel-slot~="viewport"][data-carousel-state~="dragging"] {
        cursor: var(--ui-carousel-cursor--grabbing);
      }
    
      :where(ui-carousel, [data-ui~="carousel"]) [data-carousel-slot~="container"] {
        display: flex;
        --_gap-len: var(--_gap-resolved, var(--ui-carousel-gap));
        --_gap-num: var(--_gap-resolved, var(--ui-carousel-gap));
        gap: calc(var(--_gap-len) + var(--_gap-num) * var(--spacing));
        /* the rubber band past an end, springing back on release */
        transition: translate var(--ui-carousel-settle-duration) var(--ui-carousel-settle-ease);
      }
    
      :where(ui-carousel, [data-ui~="carousel"])
        [data-carousel-state~="dragging"]
        > [data-carousel-slot~="container"] {
        transition: none;
      }
    
      :where(ui-carousel, [data-ui~="carousel"])
        :is(
          [data-carousel-axis="y"]
            [data-carousel-slot~="container"]:not([data-carousel-slot~="thumbs"] *),
          [data-carousel-thumbs-axis="y"] [data-carousel-slot~="container"]
        ) {
        flex-direction: column;
        block-size: 100%;
      }
    
      :where(ui-carousel, [data-ui~="carousel"]) [data-carousel-slot~="slide"] {
        flex: 0 0 var(--ui-carousel-slide-basis);
        min-inline-size: var(--ui-carousel-slide-min-w);
        scroll-snap-align: var(--ui-carousel-snap-align);
      }
    
      :where(ui-carousel, [data-ui~="carousel"])
        [data-carousel-slot~="thumbs"]
        [data-carousel-slot~="slide"] {
        flex: 0 0 auto;
      }
    
      :where(ui-carousel, [data-ui~="carousel"])[data-carousel-align="center"] {
        --ui-carousel-snap-align: center;
      }
    
      :where(ui-carousel, [data-ui~="carousel"])[data-carousel-align="end"] {
        --ui-carousel-snap-align: end;
      }
    
      @media (prefers-reduced-motion: no-preference) {
        :where(ui-carousel, [data-ui~="carousel"]) [data-carousel-slot~="viewport"] {
          scroll-behavior: smooth;
        }
      }
    }
    // primitives/carousel/carousel.js
    "use strict";
    /**
     * @fileoverview `<ui-carousel>` — HTML web component for carousels.
     * @description Light-DOM custom element that wraps standard carousel markup
     * and owns the carousel's lifecycle: it initializes on connect (via
     * `Carousel.initRoot`) and tears down on disconnect, so dynamically inserted
     * or SPA-swapped carousels need no manual wiring.
     *
     * The element *is* the carousel root — CSS and `base/carousel.js` target
     * `:is(ui-carousel, [data-ui~="carousel"])` directly, and `data-carousel-*`
     * configuration attributes are read off the element (see base/carousel.js for
     * the full attribute reference). No shadow DOM; children are regular markup.
     *
     * Carousels inside a closed `<dialog>` defer initialization until the dialog
     * first opens (a closed dialog is `display: none`, so the viewport cannot be
     * measured).
     *
     * @example
     * <ui-carousel data-carousel-loop="true">
     *   <div data-carousel-slot="viewport">
     *     <div data-carousel-slot="container">
     *       <div data-carousel-slot="slide">Slide 1</div>
     *       <div data-carousel-slot="slide">Slide 2</div>
     *       <div data-carousel-slot="slide">Slide 3</div>
     *     </div>
     *   </div>
     *   <button type="button" data-carousel-slot="prev">Prev</button>
     *   <button type="button" data-carousel-slot="next">Next</button>
     * </ui-carousel>
     */
    import { Carousel } from "../../base/carousel.js";
    import { ZazzElement, defineZazzElement } from "../../base/zazz-element.js";
    class UiCarouselElement extends ZazzElement {
        setup(signal) {
            const dialog = this.closest("dialog");
            if (dialog && !dialog.open) {
                // Closed dialogs are display:none — the viewport can't be measured.
                // Initialize on the dialog's open instead (zazz:dialog-open).
                dialog.addEventListener("zazz:dialog-open", () => this.init(), { signal });
                return;
            }
            this.init();
        }
        teardown() {
            // Aborting removes every listener and observer the engine bound and
            // restores the markup (slide order, the template dot, state tokens).
            this._carouselController?.abort();
            delete this._carouselController;
            // Allow re-initialization if the element is re-inserted.
            this.removeAttribute("data-carousel-init");
        }
        /**
         * @description Initializes the carousel. Idempotent — already-initialized
         * roots and roots inside closed dialogs are skipped by `initRoot`.
         */
        init() {
            Carousel.initRoot(this);
        }
        /**
         * @returns The carousel API (`goTo`, `goToNext`, `goToPrev`, `selectedSnap`,
         * `play`, `stop`), or null before initialization.
         */
        get api() {
            return this._carousel ?? null;
        }
    }
    defineZazzElement("ui-carousel", UiCarouselElement);
    export { UiCarouselElement };

    Behavior

    primitives/carousel/carousel.js

    <ui-carousel> — HTML web component for carousels. Light-DOM custom element that wraps standard carousel markup and owns the carousel's lifecycle: it initializes on connect (via Carousel.initRoot) and tears down on disconnect, so dynamically inserted or SPA-swapped carousels need no manual wiring.

    The element *is* the carousel root — CSS and base/carousel.js target :is(ui-carousel, [data-ui~="carousel"]) directly, and data-carousel-* configuration attributes are read off the element (see base/carousel.js for the full attribute reference). No shadow DOM; children are regular markup.

    Carousels inside a closed <dialog> defer initialization until the dialog first opens (a closed dialog is display: none, so the viewport cannot be measured).

    Events: zazz:dialog-open

    Attributes

    carousel attributes
    AttributeKindValuesNotes
    data-ui="carousel"Identityfree valueIdentity token in data-ui.
    <ui-carousel>Tag formfree valueTag form; styled and, when scripted, registered under this name.
    data-carousel-alignPresetcenter endPreset: a named bundle of values.
    data-carousel-axisPresetyPreset: a named bundle of values.
    data-carousel-draggablePresetfalsePreset: a named bundle of values.
    data-carousel-thumbs-axisPresetyPreset: a named bundle of values.
    data-carousel-slotSlotcontainer dot dots next prev slide thumbs viewportSlot: a part inside the primitive.
    data-carousel-stateStateactive dragging free gliding in-view jumping settling snappedState the kit's script writes; read it in selectors, never author it.
    data-carousel-initConfigfree valueConfiguration the kit's script reads.
    data-carousel-keyboardConfigfree valueConfiguration the kit's script reads.
    data-carousel-loopConfigfree valueConfiguration the kit's script reads.
    data-carousel-pluginsConfigfree valueConfiguration the kit's script reads.
    data-carousel-startConfigfree valueConfiguration the kit's script reads.
    data-carousel-start-indexConfigfree valueConfiguration the kit's script reads.

    Hooks

    Set a hook on :root, on a subtree, or inline on one element. A state hook (--…--hover) themes that state only; the primitive keeps its other states.

    carousel hooks
    HookDefaultState
    --ui-carousel-cursor--grabbinggrabbinggrabbing
    --ui-carousel-gap0px—
    --ui-carousel-settle-durationcalc(var(--default-transition-duration) * 2)—
    --ui-carousel-settle-easevar(--default-transition-timing-function)—
    --ui-carousel-slide-basiscalc(100% - var(--ui-carousel-gap))—
    --ui-carousel-slide-min-w0—
    --ui-carousel-snap-alignstart—

    API