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

Vue Card 컴포넌트

원문 보기 위키 갱신

Card는 유연하게 쓸 수 있는 컨테이너 컴포넌트예요. 제목, 부제목, 본문, 푸터를 하나의 카드 안에 담아 콘텐츠를 깔끔하게 묶어 줘요.

출처: 문서

본문

Vue Card Component

Card is a flexible container component.

Import

import Card from 'primevue/card';

Accessibility

Screen Reader 카드는 다양한 용도로 활용될 수 있어서 특정 role을 강제하지 않아요. 실제로 카드가 표시(presentational) 목적으로만 쓰인다면 role이 필요 없을 수도 있죠. 모든 유효한 속성은 컨테이너 요소로 전달되기 때문에, region 같은 landmark role을 써야 한다면 role 프로퍼티를 사용하면 돼요. Keyboard Support 이 컴포넌트에는 인터랙티브 요소가 없어요.

<Card role="region">
    Content
</Card>

Advanced

Card는 콘텐츠를 배치하기 위해 header, title, subtitle, content, footer라는 이름의 템플릿을 제공해요.

<Card style="width: 25rem; overflow: hidden">
    <template #header>
        <img alt="user header" src="/images/usercard.png" />
    </template>
    <template #title>Advanced Card</template>
    <template #subtitle>Card subtitle</template>
    <template #content>
        <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>
    </template>
    <template #footer>
        <div class="flex gap-4 mt-1">
            <Button label="Cancel" severity="secondary" variant="outlined" class="w-full" />
            <Button label="Save" class="w-full" />
        </div>
    </template>
</Card>
Composition API Example
<template>
    <Card style="width: 25rem; overflow: hidden">
        <template #header>
            <img alt="user header" src="https://primefaces.org/cdn/primevue/images/usercard.png" />
        </template>
        <template #title>Advanced Card</template>
        <template #subtitle>Card subtitle</template>
        <template #content>
            <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>
        </template>
        <template #footer>
            <div class="flex gap-4 mt-1">
                <Button label="Cancel" severity="secondary" variant="outlined" class="w-full" />
                <Button label="Save" class="w-full" />
            </div>
        </template>
    </Card>
</template>

<script setup>
<\/script>

Basic

간단한 Card는 title 프로퍼티와 자식 콘텐츠로 만들어요.

<Card>
    <template #title>Simple Card</template>
    <template #content>
        <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>
    </template>
</Card>

Card

Props

Name Type Default Description
dt any - It generates scoped CSS variables using design tokens for the component.
pt PassThrough - Used to pass attributes to DOM elements inside the component.
ptOptions any - Used to configure passthrough(pt) options of the component.
unstyled boolean false When enabled, it removes component related styles in the core.

Pass Through Options

Name Type Description
root CardPassThroughOptionType Used to pass attributes to the root's DOM element.
header CardPassThroughOptionType Used to pass attributes to the header's DOM element.
body CardPassThroughOptionType Used to pass attributes to the body's DOM element.
caption CardPassThroughOptionType Used to pass attributes to the caption's DOM element.
title CardPassThroughOptionType Used to pass attributes to the title's DOM element.
subtitle CardPassThroughOptionType Used to pass attributes to the subtitle's DOM element.
content CardPassThroughOptionType Used to pass attributes to the content's DOM element.
footer CardPassThroughOptionType Used to pass attributes to the footer's DOM element.
hooks any Used to manage all lifecycle hooks.

Theming

CSS Classes

Class Description
p-card Class name of the root element
p-card-header Class name of the header element
p-card-body Class name of the body element
p-card-caption Class name of the caption element
p-card-title Class name of the title element
p-card-subtitle Class name of the subtitle element
p-card-content Class name of the content element
p-card-footer Class name of the footer element

Design Tokens

Token CSS Variable Description
card.background --p-card-background Background of root
card.border.radius --p-card-border-radius Border radius of root
card.color --p-card-color Color of root
card.shadow --p-card-shadow Shadow of root
card.body.padding --p-card-body-padding Padding of body
card.body.gap --p-card-body-gap Gap of body
card.caption.gap --p-card-caption-gap Gap of caption
card.title.font.size --p-card-title-font-size Font size of title
card.title.font.weight --p-card-title-font-weight Font weight of title
card.subtitle.color --p-card-subtitle-color Color of subtitle

더 알아보기 (Learn more)