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

Card

원문 보기 위키 갱신

복합 구성(compound composition)을 갖춘, 스타일 없는 유연한 컨테이너 컴포넌트예요.

출처: 문서

본문

기능 (Features)

  • 여덟 개의 하위 컴포넌트로 구성된 복합 API: Root, Header, Body, Caption, Title, Subtitle, Content, Footer
  • 유연한 콘텐츠 구조: 하위 컴포넌트를 어떤 조합으로든 구성 가능
  • Root에서 모든 하위 컴포넌트로 컨텍스트 공유

사용법 (Usage)

import { Card } from 'primereact/card';
<Card.Root>
    <Card.Header />
    <Card.Body>
        <Card.Caption>
            <Card.Title />
            <Card.Subtitle />
        </Card.Caption>
        <Card.Content />
        <Card.Footer />
    </Card.Body>
</Card.Root>

동작 (Behavior)

다형적 렌더링 (Polymorphic Rendering)

어떤 하위 컴포넌트에서든 as를 사용해 렌더링할 HTML 요소를 바꿀 수 있어요.

<Card.Root as="article">
    <Card.Header as="figure">
        <img src="/photo.jpg" alt="Photo" />
    </Card.Header>
    <Card.Body as="section">
        <Card.Title as="h2">Title</Card.Title>
        <Card.Content as="main">...</Card.Content>
    </Card.Body>
</Card.Root>

기본 요소: Root=div, Header=div, Body=div, Caption=div, Title=div, Subtitle=div, Content=div, Footer=div.

렌더 함수 자식 (Render Function Children)

하위 컴포넌트는 children으로 렌더 함수를 받아 컴포넌트 인스턴스에 접근할 수 있어요.

<Card.Content>{(instance) => <p>Card ID: {instance.card?.id}</p>}</Card.Content>

Pass Through

<DocPTViewer name="card-pt" components={['CardRoot']} />

API

CardRoot

Attribute Value
data-scope card
data-part root
Label Type Description
root CardRootPassThroughType<HTMLAttributes> Used to pass attributes to the root's DOM element.
body CardRootPassThroughType<HTMLAttributes> Used to pass attributes to the body's DOM element.
header CardRootPassThroughType<HTMLAttributes> Used to pass attributes to the header's DOM element.
title CardRootPassThroughType<HTMLAttributes> Used to pass attributes to the title's DOM element.
subtitle CardRootPassThroughType<HTMLAttributes> Used to pass attributes to the subtitle's DOM element.
caption CardRootPassThroughType<HTMLAttributes> Used to pass attributes to the caption's DOM element.
content CardRootPassThroughType<HTMLAttributes> Used to pass attributes to the content's DOM element.
footer CardRootPassThroughType<HTMLAttributes> Used to pass attributes to the footer's DOM element.

CardHeader

Label Type Description
root CardHeaderPassThroughType<HTMLAttributes> Used to pass attributes to the root's DOM element.

CardBody

Label Type Description
root CardBodyPassThroughType<HTMLAttributes> Used to pass attributes to the root's DOM element.

CardCaption

Label Type Description
root CardCaptionPassThroughType<HTMLAttributes> Used to pass attributes to the root's DOM element.

CardTitle

Label Type Description
root CardTitlePassThroughType<HTMLAttributes> Used to pass attributes to the root's DOM element.

CardSubtitle

Label Type Description
root CardSubtitlePassThroughType<HTMLAttributes> Used to pass attributes to the root's DOM element.

CardContent

Label Type Description
root CardContentPassThroughType<HTMLAttributes> Used to pass attributes to the root's DOM element.

CardFooter

Label Type Description
root CardFooterPassThroughType<HTMLAttributes> Used to pass attributes to the root's DOM element.

접근성 (Accessibility)

스크린 리더 (Screen Reader)

Card는 암시적 ARIA role이 없는 구조적 컨테이너예요. 카드가 독립된 콘텐츠 영역을 나타낸다면 Card.Root에 role="region"을 적용하고 aria-label이나 aria-labelledby로 접근 가능한 이름을 제공하세요.

키보드 지원 (Keyboard Support)

Card에는 내장 키보드 상호작용이 없어요. 키보드 동작은 카드 안에 놓인 상호작용 요소(버튼, 링크, 폼 컨트롤)에 따라 달라져요.

더 알아보기 (Learn more)