Skip to content

Card

Introduction

The Card component provides a versatile container for displaying related content. It uses semantic HTML and ensures proper heading structure and content organization.

When to use

  • Featured content sections
  • Product displays
  • Blog post previews
  • Service highlights
  • Team member profiles
  • Any grouped content that benefits from visual containment

Usage

---
import { Card } from 'accessible-astro-components'
---
<Card
img="path/to/image.jpg"
url="/blog/post"
title="Card Title"
>
<p>This is the card content that can include any HTML.</p>
</Card>

Props

PropTypeDefaultDescription
urlstring''URL for the card’s link wrapper
imgstring''Path to the card’s image
titlestring''Title text for the card
classstring''Additional CSS classes to apply to the card

Accessibility features

  • Uses semantic HTML structure
  • Proper heading hierarchy with configurable levels
  • Images include proper alt text support
  • Links are properly structured for keyboard navigation
  • Focus states are clearly visible
  • Color contrast meets WCAG guidelines

Styling

.card {
--card-padding: 1rem;
--card-radius: 0.5rem;
--card-color: var(--sl-color-gray-5);
--card-bg: var(--sl-color-gray-7);
}

Interactive example

Example card

This is an example of the Card component with an image, title, and custom content.

Your name