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

Card

원문 보기 위키 갱신

헤더(header), 본문(body), 푸터(footer)를 갖춘 카드 안에 콘텐츠를 표시하는 컴포넌트예요. 제목과 설명을 지정하거나 variant로 스타일을 바꿀 수 있어요.

출처: Nuxt UI

본문

헤더(header), 본문(body), 푸터(footer)를 갖춘 카드 안에 콘텐츠를 표시해요.

사용법

header, default, footer 슬롯을 사용해서 카드에 콘텐츠를 넣을 수 있어요.

<template>
  <UCard>
    <Placeholder class="h-32" />
  
    <template #header>
      <Placeholder class="h-8" />
    </template>
    <template #footer>
      <Placeholder class="h-8" />
    </template></UCard>
</template>

타이틀 (Title) 4.7+

title prop으로 카드 헤더의 제목을 설정할 수 있어요.

<template>
  <UCard title="Card with title" class="w-full">
    <Placeholder class="h-32" />
  </UCard>
</template>

설명 (Description) 4.7+

description prop으로 카드 헤더의 설명을 설정할 수 있어요.

<template>
  <UCard title="Card with description" description="Lorem ipsum dolor sit amet, consectetur adipiscing elit." class="w-full">
    <Placeholder class="h-32" />
  </UCard>
</template>

변형 (Variant)

variant prop으로 카드의 변형을 바꿀 수 있어요.

<template>
  <UCard variant="subtle">
    <Placeholder class="h-32" />
  
    <template #header>
      <Placeholder class="h-8" />
    </template>
    <template #footer>
      <Placeholder class="h-8" />
    </template></UCard>
</template>

API

Props

/**
 * Props for the Card component
 */
interface CardProps {
  /**
   * The element or component this component should render as.
   * @default 'div'
   */
  as?: any;
  title?: string | undefined;
  description?: string | undefined;
  /**
   * @default 'outline'
   */
  variant?: "solid" | "outline" | "soft" | "subtle" | undefined;
  ui?: { root?: SlotClass; header?: SlotClass; title?: SlotClass; description?: SlotClass; body?: SlotClass; footer?: SlotClass; } | undefined;
}

Slots

/**
 * Slots for the Card component
 */
interface CardSlots {
  header(): any;
  title(): any;
  description(): any;
  default(): any;
  footer(): any;
}

테마 (Theme)

export default defineAppConfig({
  ui: {
    card: {
      slots: {
        root: 'rounded-lg overflow-hidden',
        header: 'p-4 sm:px-6',
        title: 'text-highlighted font-semibold',
        description: 'mt-1 text-muted text-sm',
        body: 'p-4 sm:p-6',
        footer: 'p-4 sm:px-6'
      },
      variants: {
        variant: {
          solid: {
            root: 'bg-inverted text-inverted',
            title: 'text-inverted',
            description: 'text-dimmed'
          },
          outline: {
            root: 'bg-default ring ring-default divide-y divide-default'
          },
          soft: {
            root: 'bg-elevated/50 divide-y divide-default'
          },
          subtle: {
            root: 'bg-elevated/50 ring ring-default divide-y divide-default'
          }
        }
      },
      defaultVariants: {
        variant: 'outline'
      }
    }
  }
})

변경 이력 (Changelog)

컴포넌트와 테마의 커밋 히스토리를 참고하세요.


더 알아보기 (Learn more)