Card

A surface that groups related content. Compose with CardHeader, CardTitle, CardBody and CardFooter.

Status: stable. Category: Layout.

import { Card, CardHeader, CardTitle, CardDescription, CardBody, CardFooter } from '@glyphui/ui'

Exports: Card, CardHeader, CardTitle, CardDescription, CardBody, CardFooter, cardStyles.

Card props

PropTypeDefaultDescription
asChildboolean
padding"none" | "sm" | "md" | "lg"
variant"outline" | "ghost" | "elevated" | "interactive"

Example: Composed card

import {
  Button,
  Card,
  CardBody,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle,
  Text,
} from '@glyphui/ui'

export default function Example() {
  return (
    <Card className="max-w-sm">
      <CardHeader>
        <CardTitle>Upgrade to Pro</CardTitle>
        <CardDescription>Unlimited projects and priority support.</CardDescription>
      </CardHeader>
      <CardBody>
        <Text size="small" tone="muted">
          You are using 3 of 3 projects on the Free plan.
        </Text>
      </CardBody>
      <CardFooter>
        <Button>Upgrade</Button>
        <Button variant="ghost">Compare plans</Button>
      </CardFooter>
    </Card>
  )
}

Example: Variants

Themes can change the default variant; the editorial preset uses outline.

import { Card, CardDescription, CardTitle } from '@glyphui/ui'

export default function Example() {
  return (
    <div className="grid gap-3 sm:grid-cols-3">
      {(['outline', 'elevated', 'ghost'] as const).map((variant) => (
        <Card key={variant} variant={variant} padding="sm">
          <CardTitle>{variant}</CardTitle>
          <CardDescription>variant="{variant}"</CardDescription>
        </Card>
      ))}
    </div>
  )
}

Example: Interactive

Lifts on hover. Use asChild to make the whole card a link.

import { Card, CardDescription, CardTitle } from '@glyphui/ui'

export default function Example() {
  return (
    <Card variant="interactive" asChild className="max-w-sm">
      <a href="#card">
        <CardTitle>Getting started</CardTitle>
        <CardDescription>
          Install Glyph and write your first theme file in five minutes.
        </CardDescription>
      </a>
    </Card>
  )
}

Live page: https://glyphui.xyz/components/card