Badge Card

Draw immediate attention to specific items in a list with this clean and effective badge card.

This layout is commonly used in e-commerce shops and content feeds to highlight items that are new, featured, on sale, or have some other special status.

Screenshot of three product cards, each with a different status badge (New, Featured, Sale).

Get Source Code Preview

About this Component

The core of this component is a classic image-and-text card with an added status badge overlaid in the corner. The badge is implemented using CSS positioning to float above the rest of the card content, ensuring it's prominent without disrupting the card's underlying layout. The template includes multiple color variations for common badge types.

Features

Code Breakdown

HTML Structure

Each card is an article element with a class of .badge-card. The first element inside the main link is a div for the badge. Placing it here is straightforward and allows its text content to be read by assistive technologies. The rest of the card follows a familiar pattern with an image and a content block for the title and description.

CSS Styling

The badge placement for this component is in the positioning context. The parent card, .badge-card, is given position: relative. This establishes a boundary for any absolutely positioned children. The badge, .badge-card-badge, is then styled with position: absolute and positioned relative to its parent's edges using the top and right properties. This allows the badge to float over the other content. The pill shape of the badge is achieved with a very large border-radius.

Code

Here's the complete, self-contained code. You can change a badge's appearance by editing the modifier classes (e.g., .badge-new) or by creating your own.

View Output