ShellUI Logo
ShellUI

Card

Compound container component for organizing and displaying content with visual hierarchy.

Overview

The Card component is a compound component that provides a flexible container for organizing content with clear visual hierarchy. It uses Shell.Cn() for class merging and renders with rounded-lg border bg-card text-card-foreground shadow-sm styling.

Installation

shellui add card

Usage

Basic Card

<Card>
  <CardHeader>
    <CardTitle>Welcome to ShellUI</CardTitle>
    <CardDescription>Build beautiful Blazor applications</CardDescription>
  </CardHeader>
  <CardContent>
    <p>Your content goes here.</p>
  </CardContent>
</Card>
<Card>
  <CardHeader>
    <CardTitle>Settings</CardTitle>
    <CardDescription>Manage your account preferences</CardDescription>
  </CardHeader>
  <CardContent>
    <div class="space-y-4">
      <Label>Email Notifications</Label>
      <Switch />
    </div>
  </CardContent>
  <CardFooter>
    <Button Variant="ButtonVariant.Outline">Cancel</Button>
    <Button>Save Changes</Button>
  </CardFooter>
</Card>

Stats Card

<Card>
  <CardHeader>
    <div class="flex flex-row items-center justify-between space-y-0 pb-2">
      <CardTitle class="text-sm font-medium">Total Revenue</CardTitle>
      <span class="text-muted-foreground">$</span>
    </div>
  </CardHeader>
  <CardContent>
    <div class="text-2xl font-bold">$45,231.89</div>
    <p class="text-xs text-muted-foreground">+20.1% from last month</p>
  </CardContent>
</Card>

Custom Styling

Each sub-component accepts a Class parameter merged via Shell.Cn():

<Card Class="w-[350px]">
  <CardHeader Class="pb-2">
    <CardTitle>Compact Card</CardTitle>
  </CardHeader>
  <CardContent Class="text-sm text-muted-foreground">
    <p>Card with custom class overrides.</p>
  </CardContent>
</Card>

API Reference

Card

ParameterTypeDefaultDescription
ChildContentRenderFragmentChild sub-components
Classstring?nullAdditional CSS classes merged via Shell.Cn()

CardHeader

ParameterTypeDefaultDescription
ChildContentRenderFragmentHeader content (title, description)
Classstring?nullAdditional CSS classes

CardTitle

ParameterTypeDefaultDescription
ChildContentRenderFragmentTitle text
Classstring?nullAdditional CSS classes

CardDescription

ParameterTypeDefaultDescription
ChildContentRenderFragmentDescription text
Classstring?nullAdditional CSS classes

CardContent

ParameterTypeDefaultDescription
ChildContentRenderFragmentMain card body
Classstring?nullAdditional CSS classes

CardFooter

ParameterTypeDefaultDescription
ChildContentRenderFragmentFooter content (actions)
Classstring?nullAdditional CSS classes

Accessibility

  • Uses semantic HTML structure for proper screen reader navigation.
  • Supports keyboard focus management within interactive card content.
  • High contrast border and shadow ensure visual distinction.

On this page