astro-better-cards

Three components for navigational content: Card (a standalone link card), ChildCards (a grid of cards auto-generated from sibling pages), and PageNav (previous/next page navigation for sequential docs).

Current version: 0.2.2 --npm

Installation

$ npm install astro-better-cards

Live example

Getting Started

Install your first astro-better-* package and have something on the page in five minutes.

Card

A single link card with optional icon, title, description, and label.

import Card from 'astro-better-cards/Card.astro';

<Card
  href="/docs"
  title="Getting Started"
  description="Set up your first project in five minutes."
/>

Card props

PropTypeDefaultDescription
hrefstring(required)Destination URL
titlestringCard heading
descriptionstringCard body text
iconstringIcon image URL (light mode)
darkIconstringIcon image URL (dark mode)
cardImagestringFull-width image at top of card
labelstringBadge label in the top corner
labelFirstbooleanfalseShow label before title
variant'full' | 'compact''full'Card layout variant
comingSoonbooleanfalseGrays out and disables click

ChildCards

Generates a card grid from pages in the same content collection directory.

import ChildCards from 'astro-better-cards/ChildCards.astro';

<ChildCards
  basePath="/docs"
  currentPath="/docs/ui"
  collection={docsCollection}
/>

ChildCards props

PropTypeDescription
basePathstringRoot path of the collection
currentPathstringCurrent page path (to determine children)
collectionCollectionEntry[]The full Astro content collection array

Previous/next navigation at the bottom of a page.

import PageNav from 'astro-better-cards/PageNav.astro';

<PageNav
  prev={{ title: 'Installation', href: '/docs/install' }}
  next={{ title: 'Configuration', href: '/docs/config' }}
/>
PropTypeDescription
prev{title, href}Previous page link
next{title, href}Next page link