card

Displays a card with header, content, and footer.

PreviousNext
Login to your accountEnter your email below to login to your account
LoginLogin with Google
import { ChangeDetectionStrategy, Component } from '@angular/core';

import { ZardButtonComponent } from '@/shared/components/button/button.component';
import { ZardCardImports } from '@/shared/components/card/card.imports';
import { ZardIdDirective } from '@/shared/core';

@Component({
  selector: 'z-demo-card-default',
  imports: [ZardCardImports, ZardButtonComponent, ZardIdDirective],
  template: `
    <z-card class="w-full md:w-94">
      <div z-card-header>
        <z-card-title zTitle="Login to your account" />
        <z-card-description zDescription="Enter your email below to login to your account" />
        <z-card-action>
          <button z-button type="button" zType="link" (click)="onSignUp()">Sign up</button>
        </z-card-action>
      </div>
      <div z-card-content>
        <div class="space-y-4">
          <div class="space-y-2" zardId="email" #e="zardId">
            <label
              [for]="e.id()"
              class="text-sm leading-none font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
            >
              Email
            </label>
            <input
              [id]="e.id()"
              type="email"
              placeholder="m@example.com"
              class="border-input bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring flex h-10 w-full rounded-md border px-3 py-2 text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"
              required
            />
          </div>
          <div class="space-y-2">
            <div class="flex items-center" zardId="password" #p="zardId">
              <label
                [for]="p.id()"
                class="text-sm leading-none font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
              >
                Password
              </label>
              <a href="#" class="ml-auto text-sm underline-offset-4 hover:underline">Forgot your password?</a>
            </div>
            <input
              [id]="p.id()"
              type="password"
              class="border-input bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring flex h-10 w-full rounded-md border px-3 py-2 text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"
              required
            />
          </div>
        </div>
      </div>
      <div z-card-footer class="flex-col gap-2">
        <z-button zType="default" class="w-full">Login</z-button>
        <z-button zType="outline" class="w-full">Login with Google</z-button>
      </div>
    </z-card>
  `,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ZardDemoCardDefaultComponent {
  protected onSignUp(): void {
    alert('Redirect to Sign Up');
  }
}

Installation

Copy
npx zard-cli@latest add card

Usage

import { ZardCardComponent } from '@/shared/components/card/card.component';
Copy
<z-card zTitle="Card Title" zDescription="Card Description">
  <p>Card Content</p>
</z-card>
Copy

Examples

size

Use the zSize="sm" input to set the size of the card to small. The small size variant uses smaller spacing.

Small CardThis card uses the small size variant.

The card component supports a zSize input that can be set to "sm" for a more compact appearance.

Action
import { ChangeDetectionStrategy, Component } from '@angular/core';

import { ZardButtonComponent } from '@/shared/components/button';
import { ZardCardImports } from '@/shared/components/card/card.imports';

@Component({
  selector: 'z-demo-card-small',
  imports: [ZardCardImports, ZardButtonComponent],
  template: `
    <z-card zSize="sm" class="mx-auto w-full max-w-sm">
      <z-card-header>
        <z-card-title zTitle="Small Card" />
        <z-card-description zDescription="This card uses the small size variant." />
      </z-card-header>
      <z-card-content>
        <p>
          The card component supports a zSize input that can be set to &quot;sm&quot; for a more compact appearance.
        </p>
      </z-card-content>
      <z-card-footer>
        <z-button zType="outline" zSize="sm" class="w-full">Action</z-button>
      </z-card-footer>
    </z-card>
  `,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ZardDemoCardSmallComponent {}

image

Add an image before the card header to create a card with an image.

Event coverFeaturedDesign systems meetupA practical talk on component APIs, accessibility, and shipping faster.View Event
import { NgOptimizedImage } from '@angular/common';
import { ChangeDetectionStrategy, Component } from '@angular/core';

import { ZardBadgeComponent } from '@/shared/components/badge';
import { ZardButtonComponent } from '@/shared/components/button';
import { ZardCardImports } from '@/shared/components/card/card.imports';

@Component({
  selector: 'z-demo-card-image',
  imports: [ZardCardImports, ZardButtonComponent, ZardBadgeComponent, NgOptimizedImage],
  template: `
    <z-card class="relative mx-auto w-full min-w-sm pt-0">
      <div class="absolute inset-0 z-30 aspect-video bg-black/35"></div>
      <img
        ngSrc="https://avatar.vercel.sh/shadcn1"
        alt="Event cover"
        class="relative z-20 aspect-video w-full object-cover brightness-60 grayscale dark:brightness-40"
        width="120"
        height="120"
      />
      <z-card-header>
        <z-card-action>
          <z-badge zType="secondary">Featured</z-badge>
        </z-card-action>
        <z-card-title zTitle="Design systems meetup" />
        <z-card-description
          zDescription="A practical talk on component APIs, accessibility, and shipping
          faster."
        />
      </z-card-header>
      <z-card-footer>
        <z-button class="w-full">View Event</z-button>
      </z-card-footer>
    </z-card>
  `,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ZardDemoCardImageComponent {}

API Reference

z-card, [z-card]Component

A structured container for displaying content with optional header and footer sections.

PropertyDescriptionTypeDefault
[class] Custom CSS classes ClassValue ''
[zSize] Size variant of the card 'default' | 'sm' 'default'

z-card-header, [z-card-header]Component

Container for card title, description, and optional action.

PropertyDescriptionTypeDefault
[zHeaderBorder] Adds a bottom border to the header boolean false

z-card-title, [z-card-title]Component

Card title text or template.

PropertyDescriptionTypeDefault
[class] Custom CSS classes ClassValue ''
[zTitle] Title content — string or template reference string | TemplateRef<void> | undefined -

z-card-description, [z-card-description]Component

Card description text or template.

PropertyDescriptionTypeDefault
[class] Custom CSS classes ClassValue ''
[zDescription] Description content — string or template reference string | TemplateRef<void> | undefined -

z-card-action, [z-card-action]Component

Action button displayed in the card header.

PropertyDescriptionTypeDefault
[class] Custom CSS classes ClassValue ''

z-card-content, [z-card-content]Component

Main content area of the card.

PropertyDescriptionTypeDefault
[class] Custom CSS classes ClassValue ''

z-card-footer, [z-card-footer]Component

Footer section of the card.

PropertyDescriptionTypeDefault
[class] Custom CSS classes ClassValue ''
[zFooterBorder] Adds a top border to the footer boolean false
github iconwhatsapp icondiscord iconX icon

Made with in Brazil. Open source and available on GitHub .