본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

카드

원문 보기 위키 갱신

카드 (Card)

카드(Card)는 제목, 부제목, 본문, 푸터를 유연하게 조합할 수 있는 컨테이너 컴포넌트예요. header, subHeader, footer 속성과 템플릿을 활용하면 이미지나 버튼이 들어간 고급 카드도 간단하게 만들 수 있어요. 기본 사용법부터 접근성, Pass Through, 테마 설정까지 카드 컴포넌트의 전체 내용을 이 문서에서 확인할 수 있어요

출처: 문서

본문

접근성

스크린 리더 카드는 다양한 사용 사례에서 활용될 수 있기 때문에 특정 role이 강제되지 않아요. 사실 카드가 단순히 보여주기 위한 용도로만 사용된다면 role이 필요 없을 수도 있어요. 유효한 모든 속성은 컨테이너 요소에 전달되기 때문에, region 같은 landmark role 중 하나를 사용해야 한다면 role 프로퍼티를 사용하면 돼요. 키보드 지원 컴포넌트에는 대화형 요소가 포함되어 있지 않아요.

고급

카드 콘텐츠는 subHeader, header, footer 프로퍼티를 사용해 더 커스터마이즈할 수 있어요.

import { Component } from '@angular/core';
import { ButtonModule } from 'primeng/button';
import { CardModule } from 'primeng/card';

@Component({
    template: `
        <div class="mb-4 p-8 flex items-center justify-center">
            <p-card [style]="{ width: '25rem', overflow: 'hidden' }">
                <ng-template #header>
                    <img alt="Card" class="w-full" src="https://primefaces.org/cdn/primeng/images/card-ng.jpg" />
                </ng-template>
                <ng-template #title> Advanced Card </ng-template>
                <ng-template #subtitle> Card subtitle </ng-template>
                <p>
                    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Inventore sed consequuntur error repudiandae numquam deserunt quisquam repellat libero asperiores earum nam nobis, culpa ratione quam perferendis esse, cupiditate neque
                    quas!
                </p>
                <ng-template #footer>
                    <div class="flex gap-4 mt-1">
                        <p-button label="Cancel" severity="secondary" class="w-full" [outlined]="true" styleClass="w-full" />
                        <p-button label="Save" class="w-full" styleClass="w-full" />
                    </div>
                </ng-template>
            </p-card>
        </div>
    `,
    standalone: true,
    imports: [ButtonModule, CardModule]
})
export class CardAdvancedDemo {}

기본

header 프로퍼티와 함께 콘텐츠를 children으로 전달해 간단한 Card를 만들 수 있어요.

import { Component } from '@angular/core';
import { CardModule } from 'primeng/card';

@Component({
    template: `
        <div class="mb-4 p-8">
            <p-card header="Simple Card">
                <p class="m-0">
                    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Inventore sed consequuntur error repudiandae numquam deserunt quisquam repellat libero asperiores earum nam nobis, culpa ratione quam perferendis esse, cupiditate neque
                    quas!
                </p>
            </p-card>
        </div>
    `,
    standalone: true,
    imports: [CardModule]
})
export class CardBasicDemo {}

Card

Card는 유연한 컨테이너 컴포넌트예요.

Props

이름 타입 기본값 설명
dt InputSignal undefined 컴포넌트의 스코프 디자인 토큰을 정의해요.
unstyled InputSignal undefined 컴포넌트를 스타일 없이 렌더링할지 여부를 나타내요.
pt InputSignal undefined 컴포넌트 내부의 DOM 요소에 속성을 전달하는 데 사용해요.
ptOptions InputSignal undefined 컴포넌트의 passthrough(pt) 옵션을 구성하는 데 사용해요.
header string - 카드의 헤더예요.
subheader string - 카드의 서브헤더예요.
style { [klass: string]: any } - 요소의 인라인 스타일이에요.
styleClass string - 요소의 클래스예요. (지원 중단)

템플릿

이름 타입 설명
header TemplateRef 커스텀 헤더 템플릿이에요.
title TemplateRef 커스텀 타이틀 템플릿이에요.
subtitle TemplateRef 커스텀 서브타이틀 템플릿이에요.
content TemplateRef 커스텀 콘텐츠 템플릿이에요.
footer TemplateRef 커스텀 푸터 템플릿이에요.

Pass Through 옵션

이름 타입 설명
root PassThroughOption<HTMLElement, I> 루트의 DOM 요소에 속성을 전달하는 데 사용해요.
header PassThroughOption<HTMLDivElement, I> 헤더의 DOM 요소에 속성을 전달하는 데 사용해요.
body PassThroughOption<HTMLDivElement, I> 바디의 DOM 요소에 속성을 전달하는 데 사용해요.
subtitle PassThroughOption<HTMLDivElement, I> 서브타이틀의 DOM 요소에 속성을 전달하는 데 사용해요.
title PassThroughOption<HTMLDivElement, I> 타이틀의 DOM 요소에 속성을 전달하는 데 사용해요.
content PassThroughOption<HTMLDivElement, I> 콘텐츠의 DOM 요소에 속성을 전달하는 데 사용해요.
footer PassThroughOption<HTMLDivElement, I> 푸터의 DOM 요소에 속성을 전달하는 데 사용해요.

테마

CSS 클래스

클래스 설명
p-card 루트 요소의 클래스 이름이에요.
p-card-header 헤더 요소의 클래스 이름이에요.
p-card-body 바디 요소의 클래스 이름이에요.
p-card-caption 캡션 요소의 클래스 이름이에요.
p-card-title 타이틀 요소의 클래스 이름이에요.
p-card-subtitle 서브타이틀 요소의 클래스 이름이에요.
p-card-content 콘텐츠 요소의 클래스 이름이에요.
p-card-footer 푸터 요소의 클래스 이름이에요.

디자인 토큰

토큰 CSS 변수 설명
card.background --p-card-background 루트의 배경이에요.
card.border.radius --p-card-border-radius 루트의 테두리 반지름이에요.
card.color --p-card-color 루트의 색상이에요.
card.shadow --p-card-shadow 루트의 그림자예요.
card.body.padding --p-card-body-padding 바디의 패딩이에요.
card.body.gap --p-card-body-gap 바디의 간격이에요.
card.caption.gap --p-card-caption-gap 캡션의 간격이에요.
card.title.font.size --p-card-title-font-size 타이틀의 폰트 크기예요.
card.title.font.weight --p-card-title-font-weight 타이틀의 폰트 굵기예요.
card.subtitle.color --p-card-subtitle-color 서브타이틀의 색상이에요.

더 알아보기 (Learn more)

이 문서에는 원문에서 추출한 별도의 관련 문서 링크가 없어요.