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.

Screenshot showing an out-of-stock product card next to a regular one for comparison.

Get Source Code Preview

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

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.

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.

View Output