Components
Card
A surface with header, title, description, content and footer parts.
Wallet
Available to spend
TZS 240,000
Verified
Use Card to group related content into one unit, such as a wallet balance or a plan. It is a container, not a control: if the whole card should be clickable, put a link inside it and stretch the link, rather than making the card a button.
Installation
pnpm dlx shadcn@latest add https://components.abdulqadirmsingi.com/r/card.json
Usage
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card";
<Card>
<CardHeader>
<CardTitle>Wallet</CardTitle>
<CardDescription>Available to spend</CardDescription>
</CardHeader>
<CardContent>TZS 240,000</CardContent>
<CardFooter>…</CardFooter>
</Card>Variants
Outline
Glass
The glass variant blurs whatever is behind it, so it needs a colourful or image backdrop.
Props
Every part extends its native element's props and spreads them on, including ref (React 19).
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | "default" | "outline" | "glass" | "default" | On Card. Visual style. |
| as | "h2" | "h3" | "h4" | "h5" | "h6" | "h3" | On CardTitle. The heading element, so the card fits your page's heading outline. |
| className | string | – | Merged with the built-in classes; yours win on conflicts. |
Accessibility
- A card is a plain
<div>with no role, so it adds no noise for screen readers. CardTitleis a real heading. Choose its level to match the page, and never skip levels.- The default card border is decorative; the
outlinevariant uses the stronger control-border colour.
Tokens used
--background, --foreground, --border, --control-border, --muted-foreground, and the glass variables.
Known limitations
- No image slot or clickable-card pattern yet.
- Glass text contrast has not been measured against worst-case backdrops.
Source
import { cva, type VariantProps } from "class-variance-authority";import type { ComponentProps } from "react";import { cn } from "@/lib/utils";const cardVariants = cva("flex flex-col gap-4 rounded-xl p-6 text-foreground", { variants: { variant: { default: "border border-border bg-background", outline: "border border-control-border bg-background", glass: "zuri-glass", }, }, defaultVariants: { variant: "default" },});export interface CardProps extends ComponentProps<"div">, VariantProps<typeof cardVariants> {}/** A surface that groups related content. Compose with CardHeader, CardContent and CardFooter. */export function Card({ className, variant, ...props }: CardProps) { return <div className={cn(cardVariants({ variant }), className)} {...props} />;}export function CardHeader({ className, ...props }: ComponentProps<"div">) { return <div className={cn("flex flex-col gap-1.5", className)} {...props} />;}export interface CardTitleProps extends ComponentProps<"h3"> { /** Heading element to render, so the card fits your page's heading outline. */ as?: "h2" | "h3" | "h4" | "h5" | "h6";}export function CardTitle({ as: Heading = "h3", className, ...props }: CardTitleProps) { return <Heading className={cn("text-lg font-semibold leading-tight", className)} {...props} />;}export function CardDescription({ className, ...props }: ComponentProps<"p">) { return <p className={cn("text-sm text-muted-foreground", className)} {...props} />;}export function CardContent({ className, ...props }: ComponentProps<"div">) { return <div className={cn("text-sm", className)} {...props} />;}export function CardFooter({ className, ...props }: ComponentProps<"div">) { return <div className={cn("flex flex-wrap items-center gap-2", className)} {...props} />;}export { cardVariants };