Componente

Card

Uma superfície que agrupa conteúdo relacionado. Componha-a com um cabeçalho (título, descrição, ação), conteúdo, rodapé e uma imagem opcional, em cinco tamanhos.

Anatomia e ação

Black ForestFreiburg · Autumn 2026 Taken Nov 3, 2026. Oak and beech leaves turning amber along the trail.

Options opened 0×

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

import { NgIcon, provideIcons } from '@ng-icons/core';
import { phosphorDotsThree } from '@ng-icons/phosphor-icons/regular';

import { HbButtonComponent, HbCardImports } from '@herbst/ui';

@Component({
  selector: 'hb-demo-card-anatomy',
  imports: [HbCardImports, HbButtonComponent, NgIcon],
  providers: [provideIcons({ phosphorDotsThree })],
  template: `
    <div class="flex flex-col gap-2">
      <hb-card class="max-w-sm">
        <hb-card-header hbBorder>
          <hb-card-title>Black Forest</hb-card-title>
          <hb-card-description>Freiburg · Autumn 2026</hb-card-description>
          <button
            hb-button
            hbType="ghost"
            hbSize="icon"
            hb-card-action
            aria-label="Options"
            (hbActionClick)="opened.set(opened() + 1)"
          >
            <ng-icon name="phosphorDotsThree" />
          </button>
        </hb-card-header>

        <hb-card-content>
          Taken Nov 3, 2026. Oak and beech leaves turning amber along the trail.
        </hb-card-content>

        <hb-card-footer hbBorder class="justify-end gap-2">
          <button hb-button hbType="ghost" hbSize="sm">Discard</button>
          <button hb-button hbSize="sm">Save</button>
        </hb-card-footer>
      </hb-card>

      <p class="font-mono text-[12px] text-muted-foreground">Options opened {{ opened() }}×</p>
    </div>
  `,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class HbDemoCardAnatomyComponent {
  protected readonly opened = signal(0);
}

Imagem

Autumn forestAutumn 2026Image on top, 16 / 9Image below the content, fixed height.Autumn forest

Tamanhos

Size xsPadding scales with the card size.Size smPadding scales with the card size.Size mdPadding scales with the card size.Size lgPadding scales with the card size.Size xlPadding scales with the card size.

Referência de API

hb-card

PropriedadeDescriçãoTipoPadrão
[hbSize] Escala de espaçamento do card e suas seções. 'xs' | 'sm' | 'md' | 'lg' | 'xl' 'md'
[class] Classes CSS extras mescladas no card. string ''

Sections

PropriedadeDescriçãoTipoPadrão
hb-card-header [hbBorder] Bloco de cabeçalho; hbBorder adiciona um divisor inferior. boolean false
hb-card-title / hb-card-description Título e subtítulo suave dentro do cabeçalho. slot
[hb-card-action] (hbActionClick) Ação fixada no topo-direito do cabeçalho; emite ao clicar. void
hb-card-content Corpo principal do card. slot
hb-card-footer [hbBorder] Bloco de rodapé; hbBorder adiciona um divisor superior. boolean false

hb-card-image

PropriedadeDescriçãoTipoPadrão
[hbSrc] / [hbAlt] Fonte e texto alternativo da imagem. string ''
[hbPosition] Coloca a imagem acima ou abaixo do corpo do card. 'top' | 'bottom' 'top'
[hbFit] Como a imagem preenche sua caixa. 'cover' | 'contain' 'cover'
[hbRatio] Proporção da caixa da imagem. number | null null
[hbHeight] Altura fixa da imagem em pixels (sobrepõe a proporção). number 0