Skip to content

Type to search the docs, API, and blog.

↑↓ navigate↵ openesc close
  • Zazz 0.14 alpha

    API

    Progress

    The native `<progress>`, determinate or indeterminate.

    Installation

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

    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 progress 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/progress/progress.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>
    <!-- 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 progress from jsDelivr, pinned to 0.14.2. To load the whole kit in two requests, see the CDN install.

    Examples

    Default

    62%
    <div data-ui="field">
      <label
        style="
          --display: flex;
          --items: center;
          --justify: space-between;
        "
        data-field-slot="label"
        for="f-upload"
      >
        <span>Reticulating splines…</span>
        <span
          style="
            --font-size: var(--font-size-xs);
            --text: var(--color-muted-foreground);
          "
          >62%</span
        >
      </label>
      <progress data-ui="progress" id="f-upload" max="100" value="62">62%</progress>
    </div>
    /**
     * progress.css — Progress ([data-ui~="progress"] on native <progress>)
     *
     * @layer      variables, reset, components
     * @requires   _layers.css, _variables.css, _reset.css, _properties.css (--_*-resolved)
     * @uses       appearance: none — element box becomes the track; only the fill
     *             needs vendor pseudo-elements (::-webkit-progress-value,
     *             ::-moz-progress-bar) — never combine the two vendors in one
     *             selector list (an unknown pseudo invalidates the whole rule)
     * @uses       :indeterminate — animated stripe on the element background
     * @uses       corner-shape — round by default, so circles stay circles; a hook takes any shape
     * @tokens     --ui-progress-* (@layer variables)
     * @consumedby meter.css
     */
    
    @layer variables {
      :root {
        --ui-progress-w: 100%;
        --ui-progress-h: calc(var(--spacing) * 1.5);
        --ui-progress-radius: var(--radius-full);
        --ui-progress-corner-shape: round;
        --ui-progress-bg: var(--color-muted);
        --ui-progress-track-border: 1px solid transparent;
        --ui-progress-bar-bg: var(--color-primary);
        --ui-progress-indeterminate-duration: 1s;
      }
    }
    
    @layer reset {
      /* ===========================================================================
      PROGRESS — native <progress> fill redraw
      The element box is the track (overflow clips the fill's corners); only the
      fill pseudos are redrawn, one rule per vendor.
      =========================================================================== */
    
      :where([data-ui~="progress"]) {
        --_w-len: var(--_w-resolved, var(--ui-progress-w));
        --_w-num: var(--_w-resolved, var(--ui-progress-w));
        inline-size: calc(var(--_w-len) + var(--_w-num) * var(--spacing));
        --_h-len: var(--_h-resolved, var(--ui-progress-h));
        --_h-num: var(--_h-resolved, var(--ui-progress-h));
        block-size: calc(var(--_h-len) + var(--_h-num) * var(--spacing));
        overflow: hidden;
        background-color: var(--_bg-resolved, var(--ui-progress-bg));
        border: var(--ui-progress-track-border);
        --_radius-len: var(--_radius-resolved, var(--ui-progress-radius));
        --_radius-num: var(--_radius-resolved, var(--ui-progress-radius));
        border-radius: calc(
          var(--_radius-len) + var(--_radius-num) * var(--spacing) * var(--radius-multiplier)
        );
        corner-shape: var(--_corner-shape-resolved, var(--ui-progress-corner-shape));
      }
    
      :where([data-ui~="progress"])::-webkit-progress-bar {
        background: transparent;
      }
    
      :where([data-ui~="progress"])::-webkit-progress-value {
        background-color: var(--ui-progress-bar-bg);
        border-radius: inherit;
        corner-shape: inherit;
        transition: inline-size var(--default-transition-duration)
          var(--default-transition-timing-function);
      }
    
      :where([data-ui~="progress"])::-moz-progress-bar {
        background-color: var(--ui-progress-bar-bg);
        border-radius: inherit;
        corner-shape: inherit;
      }
    
      /* Stripe on the element itself so it renders the same in every engine; the
         vendor fills go transparent to avoid a phantom bar. Percentage stops in a
         square tile wrap seamlessly at 45°, and animating exactly one tile keeps
         the loop jump-free; the padding-box clip keeps stripes out of the border. */
      :where([data-ui~="progress"]:indeterminate) {
        --_stripe: color-mix(in oklch, var(--ui-progress-bar-bg) 30%, transparent);
        background-image: linear-gradient(
          -45deg,
          var(--_stripe) 25%,
          transparent 25% 50%,
          var(--_stripe) 50% 75%,
          transparent 75%
        );
        background-size: calc(var(--spacing) * 4) calc(var(--spacing) * 4);
        background-origin: padding-box;
        background-clip: padding-box;
      }
    
      :where([data-ui~="progress"]:indeterminate)::-webkit-progress-value {
        background: transparent;
      }
    
      :where([data-ui~="progress"]:indeterminate)::-moz-progress-bar {
        background: transparent;
      }
    
      @media (prefers-reduced-motion: no-preference) {
        :where([data-ui~="progress"]:indeterminate) {
          animation: ui-progress-slide var(--ui-progress-indeterminate-duration) linear infinite;
        }
      }
    
      @keyframes ui-progress-slide {
        from {
          background-position: 0 0;
        }
    
        to {
          background-position: calc(var(--spacing) * 4) 0;
        }
      }
    }

    Indeterminate

    <progress data-ui="progress" aria-label="Loading"></progress>
    /**
     * progress.css — Progress ([data-ui~="progress"] on native <progress>)
     *
     * @layer      variables, reset, components
     * @requires   _layers.css, _variables.css, _reset.css, _properties.css (--_*-resolved)
     * @uses       appearance: none — element box becomes the track; only the fill
     *             needs vendor pseudo-elements (::-webkit-progress-value,
     *             ::-moz-progress-bar) — never combine the two vendors in one
     *             selector list (an unknown pseudo invalidates the whole rule)
     * @uses       :indeterminate — animated stripe on the element background
     * @uses       corner-shape — round by default, so circles stay circles; a hook takes any shape
     * @tokens     --ui-progress-* (@layer variables)
     * @consumedby meter.css
     */
    
    @layer variables {
      :root {
        --ui-progress-w: 100%;
        --ui-progress-h: calc(var(--spacing) * 1.5);
        --ui-progress-radius: var(--radius-full);
        --ui-progress-corner-shape: round;
        --ui-progress-bg: var(--color-muted);
        --ui-progress-track-border: 1px solid transparent;
        --ui-progress-bar-bg: var(--color-primary);
        --ui-progress-indeterminate-duration: 1s;
      }
    }
    
    @layer reset {
      /* ===========================================================================
      PROGRESS — native <progress> fill redraw
      The element box is the track (overflow clips the fill's corners); only the
      fill pseudos are redrawn, one rule per vendor.
      =========================================================================== */
    
      :where([data-ui~="progress"]) {
        --_w-len: var(--_w-resolved, var(--ui-progress-w));
        --_w-num: var(--_w-resolved, var(--ui-progress-w));
        inline-size: calc(var(--_w-len) + var(--_w-num) * var(--spacing));
        --_h-len: var(--_h-resolved, var(--ui-progress-h));
        --_h-num: var(--_h-resolved, var(--ui-progress-h));
        block-size: calc(var(--_h-len) + var(--_h-num) * var(--spacing));
        overflow: hidden;
        background-color: var(--_bg-resolved, var(--ui-progress-bg));
        border: var(--ui-progress-track-border);
        --_radius-len: var(--_radius-resolved, var(--ui-progress-radius));
        --_radius-num: var(--_radius-resolved, var(--ui-progress-radius));
        border-radius: calc(
          var(--_radius-len) + var(--_radius-num) * var(--spacing) * var(--radius-multiplier)
        );
        corner-shape: var(--_corner-shape-resolved, var(--ui-progress-corner-shape));
      }
    
      :where([data-ui~="progress"])::-webkit-progress-bar {
        background: transparent;
      }
    
      :where([data-ui~="progress"])::-webkit-progress-value {
        background-color: var(--ui-progress-bar-bg);
        border-radius: inherit;
        corner-shape: inherit;
        transition: inline-size var(--default-transition-duration)
          var(--default-transition-timing-function);
      }
    
      :where([data-ui~="progress"])::-moz-progress-bar {
        background-color: var(--ui-progress-bar-bg);
        border-radius: inherit;
        corner-shape: inherit;
      }
    
      /* Stripe on the element itself so it renders the same in every engine; the
         vendor fills go transparent to avoid a phantom bar. Percentage stops in a
         square tile wrap seamlessly at 45°, and animating exactly one tile keeps
         the loop jump-free; the padding-box clip keeps stripes out of the border. */
      :where([data-ui~="progress"]:indeterminate) {
        --_stripe: color-mix(in oklch, var(--ui-progress-bar-bg) 30%, transparent);
        background-image: linear-gradient(
          -45deg,
          var(--_stripe) 25%,
          transparent 25% 50%,
          var(--_stripe) 50% 75%,
          transparent 75%
        );
        background-size: calc(var(--spacing) * 4) calc(var(--spacing) * 4);
        background-origin: padding-box;
        background-clip: padding-box;
      }
    
      :where([data-ui~="progress"]:indeterminate)::-webkit-progress-value {
        background: transparent;
      }
    
      :where([data-ui~="progress"]:indeterminate)::-moz-progress-bar {
        background: transparent;
      }
    
      @media (prefers-reduced-motion: no-preference) {
        :where([data-ui~="progress"]:indeterminate) {
          animation: ui-progress-slide var(--ui-progress-indeterminate-duration) linear infinite;
        }
      }
    
      @keyframes ui-progress-slide {
        from {
          background-position: 0 0;
        }
    
        to {
          background-position: calc(var(--spacing) * 4) 0;
        }
      }
    }

    Attributes

    progress attributes
    AttributeKindValuesNotes
    data-ui="progress"Identityfree valueIdentity token in data-ui.

    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.

    progress hooks
    HookDefaultState
    --ui-progress-bar-bgvar(--color-primary)—
    --ui-progress-bgvar(--color-muted)—
    --ui-progress-corner-shaperound—
    --ui-progress-hcalc(var(--spacing) * 1.5)—
    --ui-progress-indeterminate-duration1s—
    --ui-progress-radiusvar(--radius-full)—
    --ui-progress-track-border1px solid transparent—
    --ui-progress-w100%—

    API