0.17.0

Card2

Source code

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

Basic Usage

Badge

Card 2.1

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

Card 2.2

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

Card 2.3

Lorem ipsum dolor sit amet, consectetur adipisicing elit.
---
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.

Multi-image hover gallery

Product with Gallery

Hover over the image and move left to right to see all photos.
Sale

Two Images

Card with two images in the gallery.
---
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>

How it works

Svelte Usage

<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"
/>

Props

Both callToAction and URL are supported. The button will not be displayed.

PropTypeDefaultDescription
titlestring-Title text for the card
descriptionstring-Content for the card
imagestring | Image | Image[]-Single image, array of images for gallery, or HTML string
iconstring-Name icon from set
badgestring-badge slot contents
badgeTopRightstring-badgeTopRight slot contents
badgeBottomRightstring-badgeBottomRight slot contents
badgeBottomLeftstring-badgeBottomLeft slot contents
asstringarticleHTML tag name for the wrapper
asHeaderstringh3HTML tag name for the title
urlstring-URL for the card’s link wrapper
callToActionToAction-Action button or link. See the ToAction for details.
classes.containerstring-Additional CSS classes to apply to the card wrapper
classes.titlestring-Additional CSS classes to apply to the title
classes.contentstringtext-muted-foregroundAdditional CSS classes to apply to the content container
classes.imagestring-Additional CSS classes to apply to the image container
classes.imageLayoutstringcoverAdditional CSS classes to apply to the image
classes.iconstring-Additional CSS classes to apply to the icon
classes.badgestringtop-2 left-2Additional CSS classes to apply to the badge

Notes