Out-of-stock Product Card
Clearly communicate when a product is unavailable with this "out of stock" card template.
Managing customer expectations is vital in e-commerce. This card uses multiple visual cues to make a product's unavailable status clear at a glance, preventing users from attempting to purchase an item that isn't in stock.

About this Component
This component applies a set of styles via a single modifier class (.is-out-of-stock
) to visually alter a standard product card. This approach makes it easy to toggle the out-of-stock state dynamically on your website.
Features
- Grayscale Image: The CSS
filter: grayscale(100%)
property is used to desaturate the product image, providing a strong visual cue that it is inactive. - Disabled CTA: The "Add to Cart" button is updated with the HTML
disabled
attribute, which makes it non-interactive and allows for specific "disabled" styling in CSS. - Text Overlay: A semi-transparent overlay with the text "Out of Stock" is applied on top of the image for an explicit message.
- Disabled Links: Both the main product link and the card's cursor are disabled with CSS to prevent clicks. You can remove this functionality if required.
Code Breakdown
HTML Structure
To apply the out-of-stock state, you add the .is-out-of-stock
class to the main article
element. In the HTML, the only other required change is to add the disabled
attribute to the CTA button
and optionally change its text. For better accessibility, the main product link can be given tabindex="-1"
to remove it from keyboard navigation.
CSS Styling
All the "out of stock" styles are scoped under the .is-out-of-stock
modifier class. This makes the code modular and easy to manage.
- The image's desaturation is done with
filter
. - The text overlay is created with a CSS pseudo-element (
::after
) on the image container. This pseudo-element has itscontent
property set to "Out of Stock" and is centered using Flexbox. - The disabled button's appearance is targeted using the
.is-out-of-stock
class context, applying muted colors and settingcursor: not-allowed
. - Similarly, the main product link is made unclickable by setting
pointer-events: none
. This can be removed to make it clickable.
Code
Here's the complete code. Simply add the .is-out-of-stock
class to any product card and set its button to disabled
to apply the effect.