Colour and size variants
A colour and size picker for a product page: the visual, price and stock follow the choice, and sold-out sizes are disabled.
- Tailwind
- React
- CSS
- WordPress
Description
On the page of a garment or an item that comes in variants, the buyer picks a colour from swatches and a size from buttons: the visual is recoloured, the price adapts (a limited-edition shade may cost more), the colour name shows in the legend and sizes sold out in that colour are struck through and disabled. Below the sizes, stock is announced: “In stock” or “Only 2 left” in orange for honest urgency. The add-to-cart button checks a size is chosen and confirms in a role="status" region. Everything relies on real radio buttons grouped in fieldsets with legends: arrow keys, screen readers and form submission work natively, even without script. Stock is described in JSON in an attribute, the price on each colour. 44 px swatches and sizes, visible selection ring, AA contrast in light and dark mode, colour transition removed with prefers-reduced-motion. Example: a Breton sailor jumper.
Code
Loading the code…
The code of this component in
Archive contents
produit-variantes-couleurs-html-tailwind.zip3 files · 6 Ko
- index.html9 Ko
- README.md4 Ko
- LICENSE.md1 Ko
Tags
Updated on December 2, 2026.
Reviews
No reviews yet.
In the same spirit

A limited-time offer bar: countdown to a fixed date, one-click copyable promo code and a fallback message once the offer is over.
- Tailwind
- React
- CSS
- WordPress

A sales card showing the discount that grows with the cart amount (-10% from €50, -15% from €100…) with a progress bar towards the next tier.
- Tailwind
- React
- CSS
- WordPress

A Christmas gift guide filtered by budget and theme, with the number of ideas announced and an empty state offering to show everything again.
- Tailwind
- React
- CSS
- WordPress

The last order dates for delivery before Christmas, per shipping method, with the days left worked out from the visitor’s date.
- Tailwind
- React
- CSS
- WordPress