CodingLaboratory
Lab Commands
Enter The Lab

Component Lab / ecommerce / size-stock-selector

Stable release
Back to category

Open experiment

Size and stock selector

A product variant controller that connects every size to real stock language. Available choices update the purchase readiness state; unavailable choices reveal a restock action without hiding the option from keyboard users.

Lab tested Responsive Dark mode Interactive
Version
1.0.0
Updated
2026-08-02
Dependencies
Zero
Live canvasInstant token updates
Source filesEditable and export-ready
<section class="cmp-size-stock" aria-labelledby="cmp-size-stock-title">
  <header>
    <div>
      <span>Choose your fit</span>
      <h2 id="cmp-size-stock-title">Studio shell · size</h2>
    </div>
    <a href="#size-guide">Size guide</a>
  </header>
  <div class="cmp-size-stock__options" role="radiogroup" aria-label="Product size">
    <button
      type="button"
      role="radio"
      aria-checked="false"
      tabindex="-1"
      data-size="XS"
      data-stock="4"
    >
      XS<small>4 left</small>
    </button>
    <button
      type="button"
      role="radio"
      aria-checked="true"
      tabindex="0"
      data-size="S"
      data-stock="12"
    >
      S<small>Ready</small>
    </button>
    <button
      type="button"
      role="radio"
      aria-checked="false"
      tabindex="-1"
      data-size="M"
      data-stock="8"
    >
      M<small>8 left</small>
    </button>
    <button
      type="button"
      role="radio"
      aria-checked="false"
      tabindex="-1"
      data-size="L"
      data-stock="0"
    >
      L<small>Sold out</small>
    </button>
    <button
      type="button"
      role="radio"
      aria-checked="false"
      tabindex="-1"
      data-size="XL"
      data-stock="2"
    >
      XL<small>2 left</small>
    </button>
  </div>
  <div class="cmp-size-stock__result">
    <span data-result>Size S selected · 12 in stock</span
    ><button type="button" data-restock hidden>Notify me when size L returns</button>
  </div>
  <span class="cmp-size-stock__status" aria-live="polite"></span>
</section>
No runtime reactions detected Open in Editor

Validated in the lab

Experiment report

  • Schema and source files passed
  • Responsive test passed
  • Keyboard test passed
  • No console errors

Component ingredients

Dependencies
None
Browser support
Current Chrome, Current Edge, Current Firefox, Current Safari
Version
1.0.0
Last tested
2026-08-02

Accessibility notes

  • Size buttons implement a labelled radiogroup with roving keyboard focus.
  • Availability and selected stock remain explicit text.
  • The restock action reports confirmation through a polite status.

License: MIT License for open-source use, modification, and distribution.