Scroll JS behaviour

Sticky stack cards

Meridian’s plans stack up as you scroll: each sticky card shrinks a touch and dims under the next one while its rim stays visible — pricing that narrates itself, with the sticking done purely by CSS.

Documentation

Real scenarios

The component as it is used in a product — not a specimen grid.

Four plans, one runway

Scroll and the Growth card lands on Starter, Scale on Growth — every buried card keeps a visible rim, shrinks by six percent and dims, so the stack reads as depth rather than a pile. Picking a plan stays live inside the sticky card.

Meridian · plan 1

Starter

from $0 / month

  • 2 rollout pipelines
  • 3 regions
  • Weekly digest

For the first release

In your cart · Starter

Meridian · plan 2

Growth

from $49 / month

  • 10 pipelines
  • 12 regions
  • Canary + auto-rollback

For teams shipping weekly

In your cart · Growth

Meridian · plan 3

Scale

from $199 / month

  • Unlimited pipelines
  • 24 regions
  • Progressive delivery + SLA

For fleets of services

In your cart · Scale

Meridian · plan 4

Enterprise

Custom / month

  • Private cloud
  • SOC 2 + audit trail
  • Dedicated engineer

For regulated scale

In your cart · Enterprise

Workspace seeded with the plan — billing starts after the first rollout.

Important props

Important props
Prop Type Default What it does
zone length '88vh' Each card’s zone height; the whole stacking runway is built from it (4 zones ≈ 350vh).
sticky-top calc '5.5rem + i × .875rem' Every card sticks slightly lower than the one before, so the stacked rims stay in sight.
--scs-b 0 → 1 'per card' How far the next card has covered this one; scale down to 0.94 and dimming to 0.55 derive from it.
scale-floor scale '0.94' The buried card’s scale floor; this tiny gap is what makes the stack read as depth.
fade-floor opacity '0.45' The lower card’s dimming floor; still visible, but the fresh card owns the scene.

Snippet

{{-- Sticky stack cards: vertical scroll piles the plans one under the next --}}
<div class="scs" x-data="{
        stop: () => {},
        init() {
            const cards = [...this.$root.querySelectorAll('.scs-card')];
            let frame = 0;
            const measure = () => {
                frame = 0;
                cards.forEach((card, i) => {
                    const next = cards[i + 1];
                    if (!next) return;
                    const top = card.getBoundingClientRect().top;
                    const nt = next.getBoundingClientRect().top;
                    // coverage: from the next card entering until it settles beside this one
                    const covered = Math.min(1, Math.max(0, (innerHeight - nt) / (innerHeight - top)));
                    card.style.setProperty('--scs-b', covered.toFixed(3));
                });
            };
            const schedule = () => { if (!frame) frame = requestAnimationFrame(measure); };
            addEventListener('scroll', schedule, { passive: true });
            addEventListener('resize', schedule, { passive: true });
            this.stop = () => {
                cancelAnimationFrame(frame);
                removeEventListener('scroll', schedule);
                removeEventListener('resize', schedule);
            };
            measure();
        },
        destroy() { this.stop(); },
    }">
    <div class="scs-zone"><article class="scs-card" style="--i: 0">
        <h3>Starter</h3><b>$0 / month</b>
        <ul><li>2 rollout pipelines</li><li>3 regions</li><li>Weekly report</li></ul>
    </article></div>
    <div class="scs-zone"><article class="scs-card" style="--i: 1">
        <h3>Growth</h3><b>$49 / month</b>
        <ul><li>10 pipelines</li><li>12 regions</li><li>Canary + auto-rollback</li></ul>
    </article></div>
    <div class="scs-zone"><article class="scs-card" style="--i: 2">
        <h3>Scale</h3><b>$199 / month</b>
        <ul><li>Unlimited pipelines</li><li>24 regions</li><li>Progressive delivery + SLA</li></ul>
    </article></div>
    <div class="scs-zone"><article class="scs-card" style="--i: 3">
        <h3>Enterprise</h3><b>Custom</b>
        <ul><li>Private cloud</li><li>SOC 2</li><li>Dedicated engineer</li></ul>
    </article></div>
</div>

<style>
.scs-zone { block-size: 88vh; }
.scs-card { position: sticky; inset-block-start: calc(5.5rem + var(--i) * .875rem);
            inline-size: min(100%, 34rem); margin-inline: auto; padding: 1.5rem;
            border-radius: 1.5rem; background: #fff; border: 1px solid #e4e4ef;
            scale: calc(1 - var(--scs-b, 0) * .06);
            opacity: calc(1 - var(--scs-b, 0) * .55); }
</style>
// app/Pages/Pricing.jsx — Inertia (React) page; renders the React
// snippet below unchanged, with Inertia's Link wired into the provider.
import { Link } from '@inertiajs/react';
import { NabuXUIProvider } from '@nabuxai/ui-react';
import PlanStack from '@/components/PlanStack';

export default function Pricing() {
  return (
    <NabuXUIProvider locale="en" linkComponent={Link}>
      <main className="nx-page">
        <PlanStack />
      </main>
    </NabuXUIProvider>
  );
}
// PlanStack.jsx — sticky stack cards: scroll piles the plans one under the next
import { useEffect, useRef } from 'react';
import '@nabuxai/ui-core/css';

const PLANS = [
  { id: 'starter', name: 'Starter', price: '$0 / month', perks: ['2 rollout pipelines', '3 regions', 'Weekly report'] },
  { id: 'growth', name: 'Growth', price: '$49 / month', perks: ['10 pipelines', '12 regions', 'Canary + auto-rollback'] },
  { id: 'scale', name: 'Scale', price: '$199 / month', perks: ['Unlimited pipelines', '24 regions', 'Progressive delivery + SLA'] },
  { id: 'enterprise', name: 'Enterprise', price: 'Custom', perks: ['Private cloud', 'SOC 2', 'Dedicated engineer'] },
];

export default function PlanStack() {
  const cardRefs = useRef([]);

  // One rAF-throttled scroll pass: each card learns how far the next
  // one has covered it (--scs-b), CSS does the scale + dim. Cleanup
  // on unmount, so Livewire/Inertia navigation never leaks listeners.
  useEffect(() => {
    let frame = 0;
    const measure = () => {
      frame = 0;
      const cards = cardRefs.current;
      cards.forEach((card, i) => {
        const next = cards[i + 1];
        if (!card || !next) return;
        const top = card.getBoundingClientRect().top;
        const nt = next.getBoundingClientRect().top;
        const covered = Math.min(1, Math.max(0, (innerHeight - nt) / (innerHeight - top)));
        card.style.setProperty('--scs-b', covered.toFixed(3));
      });
    };
    const schedule = () => { if (!frame) frame = requestAnimationFrame(measure); };
    window.addEventListener('scroll', schedule, { passive: true });
    window.addEventListener('resize', schedule, { passive: true });
    measure();
    return () => {
      cancelAnimationFrame(frame);
      window.removeEventListener('scroll', schedule);
      window.removeEventListener('resize', schedule);
    };
  }, []);

  return (
    <>
      <style>{`
        .scs-zone { block-size: 88vh; }
        .scs-card { position: sticky; inset-block-start: calc(5.5rem + var(--i) * .875rem);
                    inline-size: min(100%, 34rem); margin-inline: auto; padding: 1.5rem;
                    border-radius: 1.5rem; background: #fff; border: 1px solid #e4e4ef;
                    box-shadow: 0 12px 32px rgba(23, 20, 48, .08);
                    scale: calc(1 - var(--scs-b, 0) * .06);
                    opacity: calc(1 - var(--scs-b, 0) * .55); }
        .scs-card h3 { margin: 0 0 .25rem; font-size: 1.125rem; }
        .scs-card b { display: block; margin-block-end: 1rem; font-size: 1.375rem; }
        .scs-card ul { margin: 0; padding-inline-start: 1.125rem; color: #55536b; line-height: 1.9; }
      `}</style>
      {PLANS.map((plan, i) => (
        <div className="scs-zone" key={plan.id}>
          <article className="scs-card" style={{ '--i': i }} ref={(el) => { cardRefs.current[i] = el; }}>
            <h3>{plan.name}</h3>
            <b>{plan.price}</b>
            <ul>{plan.perks.map((perk) => <li key={perk}>{perk}</li>)}</ul>
          </article>
        </div>
      ))}
    </>
  );
}
<!-- PlanStack.vue — sticky stack cards: scroll piles the plans one under the next -->
<script setup lang="ts">
import { onBeforeUnmount, onMounted, ref } from 'vue';
import '@nabuxai/ui-core/css';

const plans = [
  { id: 'starter', name: 'Starter', price: '$0 / month', perks: ['2 rollout pipelines', '3 regions', 'Weekly report'] },
  { id: 'growth', name: 'Growth', price: '$49 / month', perks: ['10 pipelines', '12 regions', 'Canary + auto-rollback'] },
  { id: 'scale', name: 'Scale', price: '$199 / month', perks: ['Unlimited pipelines', '24 regions', 'Progressive delivery + SLA'] },
  { id: 'enterprise', name: 'Enterprise', price: 'Custom', perks: ['Private cloud', 'SOC 2', 'Dedicated engineer'] },
];
const cards = ref<HTMLElement[]>([]);
const setCard = (i: number) => (el: unknown) => { cards.value[i] = el as HTMLElement; };

// One rAF-throttled scroll pass sets each card's --scs-b (how far the
// next card covers it); CSS does the scale + dim. Torn down on unmount.
let frame = 0;
const measure = () => {
  frame = 0;
  cards.value.forEach((card, i) => {
    const next = cards.value[i + 1];
    if (!card || !next) return;
    const top = card.getBoundingClientRect().top;
    const nt = next.getBoundingClientRect().top;
    const covered = Math.min(1, Math.max(0, (innerHeight - nt) / (innerHeight - top)));
    card.style.setProperty('--scs-b', covered.toFixed(3));
  });
};
const schedule = () => { if (!frame) frame = requestAnimationFrame(measure); };

onMounted(() => {
  window.addEventListener('scroll', schedule, { passive: true });
  window.addEventListener('resize', schedule, { passive: true });
  measure();
});
onBeforeUnmount(() => {
  cancelAnimationFrame(frame);
  window.removeEventListener('scroll', schedule);
  window.removeEventListener('resize', schedule);
});
</script>

<template>
  <div v-for="(plan, i) in plans" :key="plan.id" class="scs-zone">
    <article :ref="setCard(i)" class="scs-card" :style="{ '--i': i }">
      <h3>{{ plan.name }}</h3>
      <b>{{ plan.price }}</b>
      <ul><li v-for="perk in plan.perks" :key="perk">{{ perk }}</li></ul>
    </article>
  </div>
</template>

<style scoped>
.scs-zone { block-size: 88vh; }
.scs-card { position: sticky; inset-block-start: calc(5.5rem + var(--i) * .875rem);
            inline-size: min(100%, 34rem); margin-inline: auto; padding: 1.5rem;
            border-radius: 1.5rem; background: #fff; border: 1px solid #e4e4ef;
            box-shadow: 0 12px 32px rgba(23, 20, 48, .08);
            scale: calc(1 - var(--scs-b, 0) * .06);
            opacity: calc(1 - var(--scs-b, 0) * .55); }
.scs-card h3 { margin: 0 0 .25rem; font-size: 1.125rem; }
.scs-card b { display: block; margin-block-end: 1rem; font-size: 1.375rem; }
.scs-card ul { margin: 0; padding-inline-start: 1.125rem; color: #55536b; line-height: 1.9; }
</style>
<!-- PlanStack.svelte — sticky stack cards: scroll piles the plans one under the next -->
<script lang="ts">
  import '@nabuxai/ui-core/css';

  const plans = [
    { id: 'starter', name: 'Starter', price: '$0 / month', perks: ['2 rollout pipelines', '3 regions', 'Weekly report'] },
    { id: 'growth', name: 'Growth', price: '$49 / month', perks: ['10 pipelines', '12 regions', 'Canary + auto-rollback'] },
    { id: 'scale', name: 'Scale', price: '$199 / month', perks: ['Unlimited pipelines', '24 regions', 'Progressive delivery + SLA'] },
    { id: 'enterprise', name: 'Enterprise', price: 'Custom', perks: ['Private cloud', 'SOC 2', 'Dedicated engineer'] },
  ];
  let cards: HTMLElement[] = $state([]);

  // One rAF-throttled scroll pass sets each card's --scs-b (how far the
  // next card covers it); CSS does the scale + dim. $effect cleans up.
  $effect(() => {
    let frame = 0;
    const measure = () => {
      frame = 0;
      cards.forEach((card, i) => {
        const next = cards[i + 1];
        if (!next) return;
        const top = card.getBoundingClientRect().top;
        const nt = next.getBoundingClientRect().top;
        const covered = Math.min(1, Math.max(0, (innerHeight - nt) / (innerHeight - top)));
        card.style.setProperty('--scs-b', covered.toFixed(3));
      });
    };
    const schedule = () => { if (!frame) frame = requestAnimationFrame(measure); };
    window.addEventListener('scroll', schedule, { passive: true });
    window.addEventListener('resize', schedule, { passive: true });
    measure();
    return () => {
      cancelAnimationFrame(frame);
      window.removeEventListener('scroll', schedule);
      window.removeEventListener('resize', schedule);
    };
  });
</script>

{#each plans as plan, i (plan.id)}
  <div class="scs-zone">
    <article bind:this={cards[i]} class="scs-card" style="--i: {i}">
      <h3>{plan.name}</h3>
      <b>{plan.price}</b>
      <ul>{#each plan.perks as perk (perk)}<li>{perk}</li>{/each}</ul>
    </article>
  </div>
{/each}

<style>
.scs-zone { block-size: 88vh; }
.scs-card { position: sticky; inset-block-start: calc(5.5rem + var(--i) * .875rem);
            inline-size: min(100%, 34rem); margin-inline: auto; padding: 1.5rem;
            border-radius: 1.5rem; background: #fff; border: 1px solid #e4e4ef;
            box-shadow: 0 12px 32px rgba(23, 20, 48, .08);
            scale: calc(1 - var(--scs-b, 0) * .06);
            opacity: calc(1 - var(--scs-b, 0) * .55); }
.scs-card h3 { margin: 0 0 .25rem; font-size: 1.125rem; }
.scs-card b { display: block; margin-block-end: 1rem; font-size: 1.375rem; }
.scs-card ul { margin: 0; padding-inline-start: 1.125rem; color: #55536b; line-height: 1.9; }
</style>