Badge
Card 2.1
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
The Card component provides a versatile container for displaying related content. It uses semantic HTML and ensures proper heading structure and content organization.
---
import { Card2, ItemGrid0 } from '@yatoday/astro-ui/astro';
---
<ItemGrid0 columns={3}>
<Card2
title="Card 2.1"
description="Lorem ipsum dolor sit amet, consectetur adipisicing elit."
image={{src: '~/assets/images/800x800.svg', alt: ''}}
url="/"
>
<Fragment slot="badge">
<div className="text-green-700 font-semibold animate-pulse">Badge</div>
</Fragment>
</Card2>
<Card2
title="Card 2.2"
description="Lorem ipsum dolor sit amet, consectetur adipisicing elit."
icon="tabler:home"
url="/"
/>
<Card2 title="Card 2.3" description="Lorem ipsum dolor sit amet, consectetur adipisicing elit." />
</ItemGrid0>
Card2 supports multiple images with an interactive hover gallery. When you pass an array of images to the image prop, the card displays invisible vertical hover zones. Moving your mouse across the image area switches between images, similar to Instagram or Tinder photo galleries.
---
import { Card2, ItemGrid0 } from '@yatoday/astro-ui/astro';
---
<ItemGrid0 columns={3}>
<Card2
title="Product with Gallery"
description="Hover over the image and move left to right to see all photos."
image={[
{src: '/images/product-1.jpg', alt: 'View 1'},
{src: '/images/product-2.jpg', alt: 'View 2'},
{src: '/images/product-3.jpg', alt: 'View 3'},
]}
url="/product"
/>
<Card2
title="Two Images"
description="Card with two images in the gallery."
image={[
{src: '/images/front.jpg', alt: 'Front view'},
{src: '/images/back.jpg', alt: 'Back view'},
]}
url="/product"
>
<Fragment slot="badgeTopRight">
<div className="bg-red-500 text-white text-xs px-2 py-1 rounded">Sale</div>
</Fragment>
</Card2>
</ItemGrid0>
<script>
import { Card2 } from '@yatoday/astro-ui/svelte';
</script>
<Card2
title="Product Gallery"
description="Interactive image gallery on hover."
image={[
{src: '/images/view-1.jpg', alt: 'View 1'},
{src: '/images/view-2.jpg', alt: 'View 2'},
{src: '/images/view-3.jpg', alt: 'View 3'},
]}
url="/product"
/>
Both callToAction and URL are supported. The button will not be displayed.
| Prop | Type | Default | Description |
|---|---|---|---|
title | string | - | Title text for the card |
description | string | - | Content for the card |
image | string | Image | Image[] | - | Single image, array of images for gallery, or HTML string |
icon | string | - | Name icon from set |
badge | string | - | badge slot contents |
badgeTopRight | string | - | badgeTopRight slot contents |
badgeBottomRight | string | - | badgeBottomRight slot contents |
badgeBottomLeft | string | - | badgeBottomLeft slot contents |
as | string | article | HTML tag name for the wrapper |
asHeader | string | h3 | HTML tag name for the title |
url | string | - | URL for the card’s link wrapper |
callToAction | ToAction | - | Action button or link. See the ToAction for details. |
classes.container | string | - | Additional CSS classes to apply to the card wrapper |
classes.title | string | - | Additional CSS classes to apply to the title |
classes.content | string | text-muted-foreground | Additional CSS classes to apply to the content container |
classes.image | string | - | Additional CSS classes to apply to the image container |
classes.imageLayout | string | cover | Additional CSS classes to apply to the image |
classes.icon | string | - | Additional CSS classes to apply to the icon |
classes.badge | string | top-2 left-2 | Additional CSS classes to apply to the badge |
Image object for a single image, or an array of Image objects for a gallery