DDBS UI
commerce

Store Motion

createMotion (Reveal and FadeImg), the Ticker that counts amounts up, useReducedMotion and createFlyToCart, the add-to-cart flying photo.

npx shadcn@latest add https://ui.develop-better-solutions.com/r/commerce-motion.json
Fullscreen
Total1,290 MAD
Reveal fades and lifts content into view once.
Stagger siblings with the delay prop.

Usage

commerce-motion-example.tsx
"use client";

import { useState } from "react";
import { Ticker, createMotion, createPriceFormatter } from "@dbs/ui";

// The host stylesheet defines .demo-reveal (and .is-in) and .demo-img; here the
// catalog ships a tiny inline version so the example is self-contained.
const { Reveal } = createMotion("demo");
const format = createPriceFormatter("MAD");

export default function CommerceMotionExample() {
  const [total, setTotal] = useState(1290);
  return (
    <div className="flex w-full max-w-md flex-col gap-4 text-sm">
      <style>{`.demo-reveal{opacity:0;transform:translateY(12px);transition:opacity .5s ease,transform .5s ease;transition-delay:var(--d,0ms)}.demo-reveal.is-in{opacity:1;transform:none}`}</style>
      <div className="flex items-center justify-between rounded-xl border border-line bg-surface p-4">
        <span className="text-ink-muted">Total</span>
        <Ticker value={total} format={format} className="text-2xl font-semibold" />
      </div>
      <div className="flex gap-2">
        <button type="button" onClick={() => setTotal((t) => t + 390)} className="rounded-full border border-line px-4 py-2">
          Add 390 MAD
        </button>
        <button type="button" onClick={() => setTotal(0)} className="rounded-full border border-line px-4 py-2">
          Clear
        </button>
      </div>
      <Reveal className="rounded-xl border border-line p-4">Reveal fades and lifts content into view once.</Reveal>
      <Reveal delay={120} className="rounded-xl border border-line p-4">
        Stagger siblings with the delay prop.
      </Reveal>
    </div>
  );
}