Skip to content
Commerce block

Stock Availability List

Availability per variant stated before the cart, because discovering it at checkout is where the basket gets abandoned.

149 linesNo dependenciesAdded 9 Sept 2026Updated 10 Sept 2026
  • stock
  • availability
  • variants
  • commerce
  • listing

What's included

  • components/stock-availability-list.tsx
  • No runtime dependencies

Works with

  • React
  • Next.js
  • Tailwind CSS
  • TypeScript

npx hoverlab add stock-availability-list

Or over MCP, from your editor's agent — no account needed.

License

Free to read, copy and install, for personal and non-commercial projects. Shipping it in client work or a paid product needs Pro ($79 once). The source lands in your repo and stops being ours — no attribution, nothing to upgrade.

Was this useful?

Start a page with this section — add more, order them, and leave with the page source.

Preview

What is actually available

"In stock" on a listing that means "one of nine variants is in stock" is the single most expensive lie in commerce UI — it is discovered at checkout, and the basket is abandoned there.

Rendered live in your current theme — this is the same component whose source is below, not a screenshot of it.

Source

components/stock-availability-list.tsx
'use client'

/**
 * <StockAvailabilityList> — Availability per variant stated before the cart, because discovering it at checkout is where the basket gets abandoned.
 *
 * "In stock" on a listing where one of nine variants is in stock is the
 * most expensive lie in commerce UI. It is discovered at checkout, and the
 * basket is abandoned there. The layout problem is surfacing per-variant
 * availability before the cart without turning the listing into a
 * spreadsheet.
 *
 * Four rows, one per variant, each with a real state. The obvious wrong
 * answer is a single badge on the product, which is the lie above.
 *
 * The counts are live numbers rather than a scarcity banner, and the detail
 * on the low row says so. "3 left" that is true is useful; "Only 3 left!"
 * that is decoration trains people to ignore both, and the second is the one
 * that ends up in a regulator's example of a dark pattern.
 *
 * The made-to-order row is the one most implementations get wrong by
 * filing it under "in stock". Six weeks is not out of stock and it is not
 * available — it is a third state, and stating it here is the difference
 * between a delighted customer and a chargeback.
 *
 * Rows are buttons with `aria-pressed` because selecting a variant is the
 * action. `status` carries the count separately from `tone` so "out" and "3
 * left" are readable without colour, which matters on the row that changes a
 * purchase decision. The demo selects the first available variant, not the
 * sold-out one.
 */

import * as React from 'react'

type Tone = 'neutral' | 'positive' | 'warning' | 'critical'

export interface StockAvailabilityListRow {
  id: string
  label: string
  detail?: string
  tone?: Tone
  /** What the badge says. Falls back to the tone name when absent. */
  status?: string
}

export interface StockAvailabilityListProps {
  heading?: string
  intro?: string
  rows?: StockAvailabilityListRow[]
  className?: string
}

/*
  Tones as complete utility classes, never assembled from fragments.
  Tailwind scans source text, so `text-${tone}-foreground` produces no
  class at all — the same failure as an undefined token, and just as
  invisible in review.
*/
const TONE_CLASS: Record<Tone, string> = {
  neutral: 'bg-muted text-muted-foreground',
  positive: 'bg-primary/10 text-primary',
  warning: 'bg-accent text-accent-foreground',
  critical: 'bg-destructive/10 text-destructive',
}

const ROWS: StockAvailabilityListRow[] = [
  { id: "row-1", label: "Small — Charcoal", detail: "Ships today if ordered before 4pm.", tone: "positive", status: "42 left" },
  { id: "row-2", label: "Medium — Charcoal", detail: "Low. The counter is live, not a scarcity banner.", tone: "warning", status: "3 left" },
  { id: "row-3", label: "Large — Charcoal", detail: "Restocking. Notify me is on the product page.", tone: "critical", status: "out" },
  { id: "row-4", label: "Small — Sand", detail: "Made to order. Six weeks, stated here rather than at checkout.", tone: "neutral", status: "6 weeks" },
]

export function StockAvailabilityList({
  heading = "What is actually available",
  intro = "\"In stock\" on a listing that means \"one of nine variants is in stock\" is the single most expensive lie in commerce UI — it is discovered at checkout, and the basket is abandoned there.",
  rows = ROWS,
  className,
}: StockAvailabilityListProps) {
  /*
    Per-instance prefix for every id this block emits.

    The literals these replaced were a latent duplicate the moment the
    block appeared twice on one document, and `aria-labelledby` on a
    duplicated id resolves to the first match -- so the second copy was
    labelled by the first copy's heading. Client component, so `useId` is
    the right tool.
  */
  const uid = React.useId()

  const [selected, setSelected] = React.useState<string | null>(rows[0]?.id ?? null)

  return (
    <section
      aria-labelledby={`${uid}-stock-availability-list-heading`}
      className={`w-full bg-background px-6 py-16 ${className ?? ''}`}
    >
      <div className="mx-auto max-w-3xl">
        <h2
          id={`${uid}-stock-availability-list-heading`}
          className="text-2xl font-semibold tracking-tight text-foreground"
        >
          {heading}
        </h2>
        <p className="mt-2 text-sm text-muted-foreground">{intro}</p>

        <ul className="mt-8 divide-y divide-border overflow-hidden rounded-xl border border-border bg-card">
          {rows.map((row) => {
            const isSelected = row.id === selected
            return (
              <li key={row.id}>
                {/*
                  A button, not a div with onClick. The row is operable, so
                  it has to be reachable by keyboard and announce its
                  selected state — aria-pressed is what carries that.
                */}
                <button
                  type="button"
                  aria-pressed={isSelected}
                  onClick={() => setSelected(row.id)}
                  className={`flex w-full items-center justify-between gap-4 px-5 py-4 text-start transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset ${
                    isSelected ? 'bg-muted/40' : ''
                  }`}
                >
                  <span className="min-w-0 flex-1">
                    <span className="block truncate text-sm font-medium text-foreground">
                      {row.label}
                    </span>
                    {row.detail ? (
                      <span className="mt-0.5 block break-words text-sm text-muted-foreground">
                        {row.detail}
                      </span>
                    ) : null}
                  </span>
                  <span
                    className={`shrink-0 rounded-full px-2.5 py-1 text-xs font-medium ${
                      TONE_CLASS[row.tone ?? 'neutral']
                    }`}
                  >
                    {row.status ?? row.tone ?? 'neutral'}
                  </span>
                </button>
              </li>
            )
          })}
        </ul>
      </div>
    </section>
  )
}

Before you paste

  • Styling is Tailwind utility classes on semantic tokens (bg-card, text-muted-foreground) — it inherits your theme instead of overriding it.
  • Nothing to install. No component library, no icon package.
  • Every prop has a default, so it renders standalone before you wire it up.

Where it goes

Drop it at components/stock-availability-list.tsx and import it where you need the section:

import { StockAvailabilityList } from '@/components/stock-availability-list'

Customize

1 of this block’s props are simple enough to drive from here. Change them and the block below re-renders — it is the same component whose source is above, not a mock of it. Everything else it accepts is in the table underneath.

Props

Read out of the component’s own type and signature, so this cannot drift from the source below. Every prop has a default — the component renders standalone before you pass it anything.

PropTypeDefault
headingstring"What is actually available"
introstring—
rowsStockAvailabilityListRow[]ROWS
classNamestring—

Not using React?

The same block rendered once to markup, wrapped as a file your framework compiles. Tailwind classes are framework-agnostic, so the design transfers intact — the behaviour does not.

This block is interactive. The markup below is its initial state with the event handlers stripped — you will need to re-wire the behaviour in your framework.

stock-availability-list.html
<!--
  Stock Availability List — markup from the Hoverlab catalog.

  This is the block rendered once to HTML and wrapped as a component
  file. It is not a port of the React source: the Tailwind classes carry
  the design, which is the part that took the work, and they are the same
  in every framework.

  This block is interactive in React and the handlers are NOT here.
  Buttons, toggles and menus render in their initial state and do
  nothing until you wire them up.
-->
<section aria-labelledby="_R_0_-stock-availability-list-heading" class="w-full bg-background px-6 py-16 ">
  <div class="mx-auto max-w-3xl">
    <h2 id="_R_0_-stock-availability-list-heading" class="text-2xl font-semibold tracking-tight text-foreground">What is actually available</h2>
    <p class="mt-2 text-sm text-muted-foreground">&quot;In stock&quot; on a listing that means &quot;one of nine variants is in stock&quot; is the single most expensive lie in commerce UI — it is discovered at checkout, and the basket is abandoned there.</p>
    <ul class="mt-8 divide-y divide-border overflow-hidden rounded-xl border border-border bg-card">
      <li>
        <button type="button" aria-pressed="true" class="flex w-full items-center justify-between gap-4 px-5 py-4 text-start transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset bg-muted/40">
          <span class="min-w-0 flex-1">
            <span class="block truncate text-sm font-medium text-foreground">Small — Charcoal</span>
            <span class="mt-0.5 block break-words text-sm text-muted-foreground">Ships today if ordered before 4pm.</span>
          </span>
          <span class="shrink-0 rounded-full px-2.5 py-1 text-xs font-medium bg-primary/10 text-primary">42 left</span>
        </button>
      </li>
      <li>
        <button type="button" aria-pressed="false" class="flex w-full items-center justify-between gap-4 px-5 py-4 text-start transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset ">
          <span class="min-w-0 flex-1">
            <span class="block truncate text-sm font-medium text-foreground">Medium — Charcoal</span>
            <span class="mt-0.5 block break-words text-sm text-muted-foreground">Low. The counter is live, not a scarcity banner.</span>
          </span>
          <span class="shrink-0 rounded-full px-2.5 py-1 text-xs font-medium bg-accent text-accent-foreground">3 left</span>
        </button>
      </li>
      <li>
        <button type="button" aria-pressed="false" class="flex w-full items-center justify-between gap-4 px-5 py-4 text-start transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset ">
          <span class="min-w-0 flex-1">
            <span class="block truncate text-sm font-medium text-foreground">Large — Charcoal</span>
            <span class="mt-0.5 block break-words text-sm text-muted-foreground">Restocking. Notify me is on the product page.</span>
          </span>
          <span class="shrink-0 rounded-full px-2.5 py-1 text-xs font-medium bg-destructive/10 text-destructive">out</span>
        </button>
      </li>
      <li>
        <button type="button" aria-pressed="false" class="flex w-full items-center justify-between gap-4 px-5 py-4 text-start transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset ">
          <span class="min-w-0 flex-1">
            <span class="block truncate text-sm font-medium text-foreground">Small — Sand</span>
            <span class="mt-0.5 block break-words text-sm text-muted-foreground">Made to order. Six weeks, stated here rather than at checkout.</span>
          </span>
          <span class="shrink-0 rounded-full px-2.5 py-1 text-xs font-medium bg-muted text-muted-foreground">6 weeks</span>
        </button>
      </li>
    </ul>
  </div>
</section>
  • This is rendered HTML, not a translation of the React source. The Tailwind classes carry the design and work in any framework.
  • It is one frame: the component in its initial state, with no props applied beyond the defaults.
  • This block is interactive in React — toggles, menus or form state. None of that survives here; the markup is the closed/default state and the handlers are gone. Re-wire them in your own framework.
  • Requires Tailwind, and the design tokens the classes reference (bg-card, text-muted-foreground, and so on). The template ZIPs ship a globals.css that defines them.

What each framework gets across the whole catalog — effects convert properly; this rung is markup.

For AI

The component, its props, the design tokens it expects and the command that installs it — as one prompt. Paste it into Claude, Cursor, v0 or ChatGPT and what they build around it will match the rest of the catalog instead of inventing its own system.

See the prompt

Used in these pages

Want the whole screen instead of this one section? Open a page and copy it entire.

8 more blocks in Product Listings

All of them free to read, copy and install — no account, no locked tiles, no watermarked preview. The whole catalog is open, and so are the API and the CLI.

Browse Product Listings

Shipping one commercially

Copying the code is free. Putting it in client work or a paid product is what Pro is for — the licence, not the access.

  • A commercial licence for everything in the catalog
  • Unlimited bundle exports, in Vue, Svelte and Tailwind
  • One payment — no subscription, nothing to renew
Pro — $79 once

More Product Listings blocks

View category
Open the full page for this block

Product Card Grid

Responsive product cards with sale badges, ratings and a wishlist button layered above the card link so it stays clickable.

Product Listings142 lines1 dep
Open the full page for this block

Faceted Filter Sidebar

Category, size, colour and price facets as proper fieldsets, with colour swatches that carry their name as well as their hue.

Product Listings220 lines1 dep
Open the full page for this block

Collection Sort Toolbar

Result count, sort and density switch — with the count in an aria-live region, since it is the only feedback a filter change gives some users.

Product Listings131 lines1 dep
Open the full page for this block

Product Comparison Table

Three products side by side with the row labels pinned through a horizontal scroll, an "only show differences" toggle that says how many rows it hid, and "best" marked only where better means something.

Product Listings341 lines1 dep
Open the full page for this block

Collection Story Split

The editorial header above a collection grid, carrying the four facts that decide a considered purchase.

Product Listings157 linesNo deps

Map and Results Split

Results on one side, a drawn map on the other, scrolling independently. The map is explicitly decorative and out of the tab order — the list is the content, not its companion.

Product Listings329 lines1 dep
Open the full page for this block

Menu Course List

A restaurant menu typeset as a bill of fare rather than a product grid — dotted leaders to the price, dietary marks as abbreviations with a key, and prices as strings so “market price” still fits.

Product Listings282 linesNo deps