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

가격 플랜

원문 보기 위키 갱신

가격 플랜 (PricingPlan)

가격 페이지에 표시할 수 있는 커스터마이즈 가능한 가격 플랜 컴포넌트예요. 제목, 설명, 가격, 기능 목록, 배지, 버튼 등을 자유롭게 구성할 수 있어요.

출처: Nuxt UI

본문

가격 페이지에 표시할 수 있는 커스터마이즈 가능한 가격 플랜이에요.

사용 방법 (Usage)

PricingPlan 컴포넌트는 제목, 설명, 가격, 기능 등을 포함한 내용을 자유롭게 커스터마이즈할 수 있는 가격 플랜을 유연하게 표시해 줘요.

<template>
  <u-pricing-plan :button="{
    label: 'Buy now'
  }" :features="[
    'One developer',
    'Unlimited projects',
    'Access to GitHub repository',
    'Unlimited patch & minor updates',
    'Lifetime access'
  ]" badge="Most popular" billing-cycle="/month" class="w-96" description="For bootstrappers and indie hackers." discount="$199" price="$249" title="Solo" />
</template>

[!TIP] See: /docs/components/pricing-plans

PricingPlans 컴포넌트를 사용하면 여러 가격 플랜을 반응형 그리드 레이아웃으로 표시할 수 있어요.

제목 (Title)

title prop을 사용하면 PricingPlan의 제목을 설정할 수 있어요.

<template>
  <UPricingPlan title="Solo" class="w-96" />
</template>

설명 (Description)

description prop을 사용하면 PricingPlan의 설명을 설정할 수 있어요.

<template>
  <UPricingPlan title="Solo" description="For bootstrappers and indie hackers." />
</template>

배지 (Badge)

badge prop을 사용하면 PricingPlan의 제목 옆에 Badge를 표시할 수 있어요.

<template>
  <UPricingPlan title="Solo" description="For bootstrappers and indie hackers." badge="Most popular" />
</template>

Badge 컴포넌트의 어떤 속성이든 전달해 커스터마이즈할 수 있어요.

<template>
  <UPricingPlan title="Solo" description="For bootstrappers and indie hackers." :badge="{
  label: 'Most popular',
  color: 'neutral',
  variant: 'solid'
}" />
</template>

가격 (Price)

price prop을 사용하면 PricingPlan의 가격을 설정할 수 있어요.

<template>
  <UPricingPlan title="Solo" description="For bootstrappers and indie hackers." price="$249" />
</template>

할인 (Discount)

discount prop을 사용하면 원래 가격 옆에 표시될 할인 가격을 설정할 수 있어요(원래 가격은 취소선으로 표시됨).

<template>
  <UPricingPlan title="Solo" description="For bootstrappers and indie hackers." price="$249" discount="$199" />
</template>

청구 정보 (Billing)

billing-cycle 및/또는 billing-period prop을 사용하면 PricingPlan의 청구 정보를 표시할 수 있어요.

<template>
  <UPricingPlan title="Solo" description="For bootstrappers and indie hackers." price="$9" billing-cycle="/month" billing-period="billed annually" />
</template>

기능 (Features)

features prop을 문자열 배열로 사용해 PricingPlan에 기능 목록을 표시할 수 있어요:

<template>
  <UPricingPlan title="Solo" description="For bootstrappers and indie hackers." price="$249" :features="[
  'One developer',
  'Unlimited projects',
  'Access to GitHub repository',
  'Unlimited patch & minor updates',
  'Lifetime access'
]" />
</template>

Nuxt:

[!TIP] See: /docs/getting-started/integrations/icons/nuxt#theme

app.config.ts의 ui.icons.success 키에서 이 아이콘을 전역으로 커스터마이즈할 수 있어요.

Vue:

[!TIP] See: /docs/getting-started/integrations/icons/vue#theme

vite.config.ts의 ui.icons.success 키에서 이 아이콘을 전역으로 커스터마이즈할 수 있어요.

다음 속성을 가진 객체 배열을 전달할 수도 있어요:

  • title: string
  • icon?: string
<script setup lang="ts">
import type { PricingPlanFeature } from '@nuxt/ui'

const features = ref<PricingPlanFeature[]>([
  {
    title: "One developer",
    icon: "i-lucide-user"
  },
  {
    title: "Unlimited projects",
    icon: "i-lucide-infinity"
  },
  {
    title: "Access to GitHub repository",
    icon: "i-lucide-github"
  },
  {
    title: "Unlimited patch & minor updates",
    icon: "i-lucide-refresh-cw"
  },
  {
    title: "Lifetime access",
    icon: "i-lucide-clock"
  }
])
</script>

<template>
  <UPricingPlan title="Solo" description="For bootstrappers and indie hackers." price="$249" :features="features" />
</template>

버튼 (Button)

Button 컴포넌트의 어떤 속성이든 가진 button prop을 사용해 PricingPlan 하단에 버튼을 표시할 수 있어요.

<template>
  <UPricingPlan title="Solo" description="For bootstrappers and indie hackers." price="$249" :features="[
  'One developer',
  'Unlimited projects',
  'Access to GitHub repository',
  'Unlimited patch & minor updates',
  'Lifetime access'
]" :button="{
  label: 'Buy now'
}" />
</template>

[!TIP]

onClick 필드를 사용해 플랜 구매를 트리거하는 클릭 핸들러를 추가할 수 있어요.

변형 (Variant)

variant prop을 사용하면 PricingPlan의 변형을 바꿀 수 있어요.

<template>
  <UPricingPlan title="Solo" description="For bootstrappers and indie hackers." price="$249" :features="[
  'One developer',
  'Unlimited projects',
  'Access to GitHub repository',
  'Unlimited patch & minor updates',
  'Lifetime access'
]" :button="{
  label: 'Buy now'
}" variant="subtle" />
</template>

방향 (Orientation)

orientation prop을 사용하면 PricingPlan의 방향을 바꿀 수 있어요. 기본값은 vertical이에요.

<template>
  <UPricingPlan title="Solo" description="For bootstrappers and indie hackers." price="$249" :features="[
  'One developer',
  'Unlimited projects',
  'Access to GitHub repository',
  'Lifetime access'
]" :button="{
  label: 'Buy now'
}" orientation="horizontal" variant="outline" />
</template>

태그라인 (Tagline)

tagline prop을 사용하면 가격 위에 태그라인 텍스트를 표시할 수 있어요.

<template>
  <UPricingPlan title="Solo" description="For bootstrappers and indie hackers." price="$249" :features="[
  'One developer',
  'Unlimited projects',
  'Access to GitHub repository',
  'Lifetime access'
]" :button="{
  label: 'Buy now'
}" orientation="horizontal" tagline="Pay once, own it forever" />
</template>

약관 (Terms)

terms prop을 사용하면 가격 아래에 약관을 표시할 수 있어요.

<template>
  <UPricingPlan title="Solo" description="For bootstrappers and indie hackers." price="$249" :features="[
  'One developer',
  'Unlimited projects',
  'Access to GitHub repository',
  'Lifetime access'
]" :button="{
  label: 'Buy now'
}" orientation="horizontal" tagline="Pay once, own it forever" terms="Invoices and receipts available." />
</template>

강조 (Highlight)

highlight prop을 사용하면 PricingPlan 주변에 강조 테두리를 표시할 수 있어요.

<template>
  <UPricingPlan title="Solo" description="For bootstrappers and indie hackers." price="$249" :features="[
  'One developer',
  'Unlimited projects',
  'Access to GitHub repository',
  'Unlimited patch & minor updates',
  'Lifetime access'
]" :button="{
  label: 'Buy now'
}" highlight />
</template>

확대 (Scale)

scale prop을 사용하면 다른 플랜보다 큰 가격 플랜을 만들 수 있어요.

[!NOTE] See: /docs/components/pricing-plans#scale

단독으로는 보여주기 어렵기 때문에 PricingPlans의 scale 예시를 확인해 어떻게 동작하는지 살펴보세요.

API

Props

/**
 * Props for the PricingPlan component
 */
interface PricingPlanProps {
  /**
   * The element or component this component should render as.
   * @default 'div'
   */
  as?: any;
  title?: string | undefined;
  description?: string | undefined;
  /**
   * Display a badge next to the title.
   * Can be a string or an object.
   * `{ color: 'primary', variant: 'subtle' }`{lang="ts-type"}
   */
  badge?: string | BadgeProps | undefined;
  /**
   * The unit price period that appears next to the price.
   * Typically used to show the recurring interval.
   */
  billingCycle?: string | undefined;
  /**
   * Additional billing context that appears above the billing cycle.
   * Typically used to show the actual billing frequency.
   */
  billingPeriod?: string | undefined;
  /**
   * The current price of the plan.
   * When used with `discount`, this becomes the original price.
   */
  price?: string | undefined;
  /**
   * The discounted price of the plan.
   * When provided, the `price` prop will be displayed as strikethrough.
   */
  discount?: string | undefined;
  /**
   * Display a list of features under the price.
   * Can be an array of strings or an array of objects.
   */
  features?: string[] | PricingPlanFeature[] | undefined;
  /**
   * Display a buy button at the bottom.
   * `{ size: 'lg', block: true }`{lang="ts-type"}
   * Use the `onClick` field to add a click handler.
   */
  button?: ButtonProps | undefined;
  /**
   * Display a tagline highlighting the pricing value proposition.
   */
  tagline?: string | undefined;
  /**
   * Display terms at the bottom.
   */
  terms?: string | undefined;
  /**
   * The orientation of the pricing plan.
   * @default 'vertical'
   */
  orientation?: "vertical" | "horizontal" | undefined;
  /**
   * @default 'outline'
   */
  variant?: "soft" | "solid" | "outline" | "subtle" | undefined;
  /**
   * Display a ring around the pricing plan to highlight it.
   */
  highlight?: boolean | undefined;
  /**
   * Enlarge the plan to make it more prominent.
   */
  scale?: boolean | undefined;
  ui?: { root?: SlotClass; header?: SlotClass; body?: SlotClass; footer?: SlotClass; titleWrapper?: SlotClass; title?: SlotClass; description?: SlotClass; priceWrapper?: SlotClass; price?: SlotClass; discount?: SlotClass; billing?: SlotClass; billingPeriod?: SlotClass; billingCycle?: SlotClass; features?: SlotClass; feature?: SlotClass; featureIcon?: SlotClass; featureTitle?: SlotClass; badge?: SlotClass; button?: SlotClass; tagline?: SlotClass; terms?: SlotClass; } | undefined;
}

Slots

/**
 * Slots for the PricingPlan component
 */
interface PricingPlanSlots {
  badge(): any;
  title(): any;
  description(): any;
  price(): any;
  discount(): any;
  billing(): any;
  features(): any;
  button(): any;
  header(): any;
  body(): any;
  footer(): any;
  tagline(): any;
  terms(): any;
}

테마 (Theme)

export default defineAppConfig({
  ui: {
    pricingPlan: {
      slots: {
        root: 'relative grid rounded-lg p-6 lg:p-8 xl:p-10 gap-6',
        header: '',
        body: 'flex flex-col min-w-0',
        footer: 'flex flex-col gap-6 items-center',
        titleWrapper: 'flex items-center gap-3',
        title: 'text-highlighted truncate text-2xl sm:text-3xl text-pretty font-semibold',
        description: 'text-muted text-base text-pretty mt-2',
        priceWrapper: 'flex items-center gap-1',
        price: 'text-highlighted text-3xl sm:text-4xl font-semibold',
        discount: 'text-muted line-through text-xl sm:text-2xl',
        billing: 'flex flex-col justify-between min-w-0',
        billingPeriod: 'text-toned truncate text-xs font-medium',
        billingCycle: 'text-muted truncate text-xs font-medium',
        features: 'flex flex-col gap-3 flex-1 mt-6 grow-0',
        feature: 'flex items-center gap-2 min-w-0',
        featureIcon: 'size-5 shrink-0 text-primary',
        featureTitle: 'text-muted text-sm truncate',
        badge: '',
        button: '',
        tagline: 'text-base font-semibold text-default',
        terms: 'text-xs/5 text-muted text-center text-balance'
      },
      variants: {
        orientation: {
          horizontal: {
            root: 'grid-cols-1 lg:grid-cols-3 justify-between divide-y lg:divide-y-0 lg:divide-x divide-default',
            body: 'lg:col-span-2 pb-6 lg:pb-0 lg:pe-6 justify-center',
            footer: 'lg:justify-center lg:items-center lg:p-6 lg:max-w-xs lg:w-full lg:mx-auto',
            features: 'lg:grid lg:grid-cols-2 lg:mt-12'
          },
          vertical: {
            footer: 'justify-end',
            priceWrapper: 'mt-6'
          }
        },
        variant: {
          solid: {
            root: 'bg-inverted',
            title: 'text-inverted',
            description: 'text-dimmed',
            price: 'text-inverted',
            discount: 'text-dimmed',
            billingCycle: 'text-dimmed',
            billingPeriod: 'text-dimmed',
            featureTitle: 'text-dimmed'
          },
          outline: {
            root: 'bg-default ring ring-default'
          },
          soft: {
            root: 'bg-elevated/50'
          },
          subtle: {
            root: 'bg-elevated/50 ring ring-default'
          }
        },
        highlight: {
          true: {
            root: 'ring-2 ring-inset ring-primary'
          }
        },
        scale: {
          true: {
            root: 'lg:scale-[1.1] lg:z-[1]'
          }
        }
      },
      compoundVariants: [
        {
          orientation: 'horizontal',
          variant: 'soft',
          class: {
            root: 'divide-accented'
          }
        },
        {
          orientation: 'horizontal',
          variant: 'subtle',
          class: {
            root: 'divide-accented'
          }
        }
      ],
      defaultVariants: {
        variant: 'outline'
      }
    }
  }
})

변경 이력 (Changelog)

컴포넌트와 테마의 커밋 이력을 확인하세요.


더 알아보기 (Learn more)