DDBS UI
commerce

Shipping Progress

The free-shipping message with a progress bar that fills as the cart grows.

npx shadcn@latest add https://ui.develop-better-solutions.com/r/store-shipping-progress.json
Fullscreen

You are 610 MAD away from free standard shipping.

Subtotal 390 MAD

Usage

store-shipping-progress-example.tsx
"use client";

import { useState } from "react";
import { ShippingProgress } from "@dbs/ui";
import { StoreScope, fmt } from "./_store";

const THRESHOLD = 1000;

export default function StoreShippingProgressExample() {
  const [subtotal, setSubtotal] = useState(390);
  return (
    <div className="w-full max-w-md">
      <StoreScope minHeight={0}>
        <div className="flex flex-col gap-5">
          <ShippingProgress remaining={Math.max(0, THRESHOLD - subtotal)} threshold={THRESHOLD} formatPrice={fmt} />
          <div className="flex items-center justify-between text-sm">
            <span>Subtotal {fmt(subtotal)}</span>
            <button
              type="button"
              onClick={() => setSubtotal((s) => (s >= THRESHOLD ? 0 : s + 260))}
              className="rounded-full border border-[var(--store-line2)] px-4 py-1.5"
            >
              {subtotal >= THRESHOLD ? "Reset" : "Add 260 MAD"}
            </button>
          </div>
        </div>
      </StoreScope>
    </div>
  );
}