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

가격표

원문 보기 위키 갱신

가격표 (PricingTable)

PricingTable은 단계별(tiered) 가격 플랜과 기능 비교를 표 형태로 보여주는 반응형 가격표 컴포넌트예요. 데스크톱에서는 비교하기 쉬운 가로 표 레이아웃, 모바일에서는 가독성 좋은 세로 카드 레이아웃으로 자동 전환해요.

출처: Nuxt UI

본문

사용법 (Usage)

PricingTable 컴포넌트는 가격 플랜을 표 형식으로 표시하는 반응형이고 커스터마이즈 가능한 방법을 제공해요. 데스크톱에서는 비교하기 쉬운 가로 표 레이아웃, 모바일에서는 가독성 좋은 세로 카드 레이아웃으로 자동 전환해요.

<template>
  <u-pricing-table :sections="[
    {
      title: 'Features',
      features: [
        {
          title: 'Number of developers',
          tiers: {
            solo: '1',
            team: '5',
            enterprise: 'Unlimited'
          }
        },
        {
          title: 'Projects',
          tiers: {
            solo: true,
            team: true,
            enterprise: true
          }
        },
        {
          title: 'GitHub repository access',
          tiers: {
            solo: true,
            team: true,
            enterprise: true
          }
        },
        {
          title: 'Updates',
          tiers: {
            solo: 'Patch & minor',
            team: 'All updates',
            enterprise: 'All updates'
          }
        },
        {
          title: 'Support',
          tiers: {
            solo: 'Community',
            team: 'Priority',
            enterprise: '24/7'
          }
        }
      ]
    },
    {
      title: 'Security',
      features: [
        {
          title: 'SSO',
          tiers: {
            solo: false,
            team: true,
            enterprise: true
          }
        },
        {
          title: 'Audit logs',
          tiers: {
            solo: false,
            team: true,
            enterprise: true
          }
        },
        {
          title: 'Custom security review',
          tiers: {
            solo: false,
            team: false,
            enterprise: true
          }
        }
      ]
    }
  ]" :tiers="[
    {
      id: 'solo',
      title: 'Solo',
      description: 'For indie hackers.',
      price: '$249',
      billingCycle: '/month',
      billingPeriod: 'billed annually',
      badge: 'Most popular',
      button: {
        label: 'Buy now',
        variant: 'subtle'
      }
    },
    {
      id: 'team',
      title: 'Team',
      description: 'For growing teams.',
      price: '$499',
      billingCycle: '/month',
      billingPeriod: 'billed annually',
      button: {
        label: 'Buy now'
      },
      highlight: true
    },
    {
      id: 'enterprise',
      title: 'Enterprise',
      description: 'For large organizations.',
      price: 'Custom',
      button: {
        label: 'Contact sales',
        color: 'neutral'
      }
    }
  ]" />
</template>

티어 (Tiers)

tiers prop을 객체 배열로 사용해 가격 플랜을 정의해요. 각 티어 객체는 다음 속성을 지원해요.

  • id: string - 티어의 고유 식별자 (필수)
  • title?: string - 가격 플랜의 이름
  • description?: string - 플랜의 짧은 설명
  • price?: string - 플랜의 현재 가격 (예: "$99", "€99", "Free")
  • discount?: string - price를 취소선으로 표시할 할인 가격 (예: "$79", "€79")
  • billingCycle?: string - 가격 옆에 표시되는 단위 가격 기간 (예: "/month", "/seat/month")
  • billingPeriod?: string - 결제 주기 위에 나타나는 추가 결제 컨텍스트 (예: "billed monthly")
  • badge?: string | BadgeProps - 제목 옆에 배지를 표시 { color: 'primary', variant: 'subtle' }
  • button?: ButtonProps - CTA 버튼 구성 { size: 'lg', block: true }
  • highlight?: boolean - 이 티어를 추천 옵션으로 시각적으로 강조할지 여부
<script setup lang="ts">
import type { PricingTableTier } from '@nuxt/ui'

const tiers = ref<PricingTableTier[]>([
  {
    id: "solo",
    title: "Solo",
    description: "For indie hackers.",
    price: "$249",
    billingCycle: "/month",
    billingPeriod: "billed annually",
    badge: "Most popular",
    button: {
      label: "Buy now",
      variant: "subtle"
    }
  },
  {
    id: "team",
    title: "Team",
    description: "For growing teams.",
    price: "$499",
    billingCycle: "/month",
    billingPeriod: "billed annually",
    button: {
      label: "Buy now"
    },
    highlight: true
  },
  {
    id: "enterprise",
    title: "Enterprise",
    description: "For large organizations.",
    price: "Custom",
    button: {
      label: "Contact sales",
      color: "neutral"
    }
  }
])
</script>

<template>
  <UPricingTable :tiers="tiers" />
</template>

섹션 (Sections)

sections prop을 사용해 기능을 논리적인 그룹으로 정리할 수 있어요. 각 섹션은 서로 다른 가격 티어에서 비교할 기능의 카테고리를 나타내요.

  • title: string - 기능 섹션의 제목

  • features: PricingTableSectionFeature[] - 각 티어에서의 사용 가능 여부가 담긴 기능 배열:

    • 각 기능은 title과 티어 ID를 값으로 매핑하는 tiers 객체가 필요해요
    • 불리언 값(true/false)은 체크 표시(✓)나 마이너스 아이콘(-)으로 표시돼요
    • 문자열 값은 텍스트로 표시돼요 (예: "Unlimited", "Up to 5 users")
    • 숫자 값은 그대로 표시돼요 (예: 10, 100)
<script setup lang="ts">
import type { PricingTableTier, PricingTableSection } from '@nuxt/ui'

const tiers = ref<PricingTableTier[]>([
  {
    id: "solo",
    title: "Solo",
    price: "$249",
    description: "For indie hackers.",
    billingCycle: "/month",
    button: {
      label: "Buy now",
      variant: "subtle"
    }
  },
  {
    id: "team",
    title: "Team",
    price: "$499",
    description: "For growing teams.",
    billingCycle: "/month",
    button: {
      label: "Buy now"
    }
  },
  {
    id: "enterprise",
    title: "Enterprise",
    price: "Custom",
    description: "For large organizations.",
    button: {
      label: "Contact sales",
      color: "neutral"
    }
  }
])
const sections = ref<PricingTableSection[]>([
  {
    title: "Features",
    features: [
      {
        title: "Number of developers",
        tiers: {
          solo: "1",
          team: "5",
          enterprise: "Unlimited"
        }
      },
      {
        title: "Projects",
        tiers: {
          solo: true,
          team: true,
          enterprise: true
        }
      }
    ]
  },
  {
    title: "Security",
    features: [
      {
        title: "SSO",
        tiers: {
          solo: false,
          team: true,
          enterprise: true
        }
      }
    ]
  }
])
</script>

<template>
  <UPricingTable :tiers="tiers" :sections="sections" />
</template>

예시 (Examples)

slot과 함께

PricingTable 컴포넌트는 콘텐츠 표시를 맞춤 구성할 수 있는 강력한 slot 커스터마이즈 옵션을 제공해요. 제네릭 slot으로 개별 요소를 커스터마이즈하거나, ID를 사용해 특정 항목을 대상으로 지정할 수 있어요.

<script setup lang="ts">
const tiers = [
  {
    id: 'solo',
    title: 'Solo',
    price: '$249',
    description: 'For indie hackers.',
    billingCycle: '/month',
    button: { label: 'Buy now', variant: 'subtle' as const }
  },
  {
    id: 'team',
    title: 'Team',
    price: '$499',
    description: 'For growing teams.',
    billingCycle: '/month',
    button: { label: 'Buy now' },
    highlight: true
  },
  {
    id: 'enterprise',
    title: 'Enterprise',
    price: 'Custom',
    description: 'For large organizations.',
    button: { label: 'Contact sales', color: 'neutral' as const }
  }
]

const sections = [
  {
    id: 'features',
    title: 'Features',
    features: [
      {
        id: 'developers',
        title: 'Number of developers',
        tiers: { solo: '1', team: '5', enterprise: 'Unlimited' }
      },
      {
        id: 'projects',
        title: 'Projects',
        tiers: { solo: true, team: true, enterprise: true }
      }
    ]
  },
  {
    id: 'security',
    title: 'Security',
    features: [
      {
        title: 'SSO',
        tiers: { solo: false, team: true, enterprise: true }
      }
    ]
  }
]
</script>

<template>
  <UPricingTable :tiers="tiers" :sections="sections">
    <!-- Customize specific tier title -->
    <template #team-title="{ tier }">
      <div class="flex items-center gap-2">
        <UIcon name="i-lucide-crown" class="size-4 text-amber-500" />
        {{ tier.title }}
      </div>
    </template>

    <!-- Customize specific section title -->
    <template #section-security-title="{ section }">
      <div class="flex items-center gap-2">
        <UIcon name="i-lucide-shield-check" class="size-4 text-green-500" />
        <span class="font-semibold text-green-700">{{ section.title }}</span>
      </div>
    </template>

    <!-- Customize specific feature value -->
    <template #feature-developers-value="{ feature, tier }">
      <template v-if="feature.tiers?.[tier.id]">
        <UBadge :label="String(feature.tiers[tier.id])" color="primary" variant="soft" />
      </template>
      <UIcon v-else name="i-lucide-x" class="size-4 text-muted" />
    </template>
  </UPricingTable>
</template>

컴포넌트는 최대한의 커스터마이즈 유연성을 위해 다양한 slot 유형을 지원해요.

Slot Type Pattern Description Example
Tier slots #{tier-id}-{element} Target specific tiers #team-title, #solo-price
Section slots #section-{id|formatted-title}-title Target specific sections #section-features-title
Feature slots #feature-{id|formatted-title}-{title|value} Target specific features #feature-developers-title
Generic slots #tier-title, #section-title, etc. Apply to all items #feature-value

[!NOTE]

id를 제공하지 않으면 slot 이름이 제목에서 자동 생성돼요 (예: "Premium Features!" → #section-premium-features-title).

API

Props

/**
 * Props for the PricingTable component
 */
interface PricingTableProps {
  /**
   * The pricing tiers to display in the table.
   * Each tier represents a pricing plan with its own title, description, price, and features.
   */
  tiers: T[];
  /**
   * The sections of features to display in the table.
   * Each section contains a title and a list of features with their availability in each tier.
   */
  sections: PricingTableSection<T>[];
  /**
   * The element or component this component should render as.
   * @default 'div'
   */
  as?: any;
  /**
   * The caption to display above the table.
   * @default t('pricingTable.caption')
   */
  caption?: string | undefined;
  ui?: { root?: SlotClass; table?: SlotClass; list?: SlotClass; item?: SlotClass; caption?: SlotClass; thead?: SlotClass; tbody?: SlotClass; tr?: SlotClass; th?: SlotClass; td?: SlotClass; tier?: SlotClass; tierWrapper?: SlotClass; tierTitleWrapper?: SlotClass; tierTitle?: SlotClass; tierDescription?: SlotClass; tierBadge?: SlotClass; tierPriceWrapper?: SlotClass; tierPrice?: SlotClass; tierDiscount?: SlotClass; tierBilling?: SlotClass; tierBillingPeriod?: SlotClass; tierBillingCycle?: SlotClass; tierButton?: SlotClass; tierFeatureIcon?: SlotClass; section?: SlotClass; sectionTitle?: SlotClass; feature?: SlotClass; featureTitle?: SlotClass; featureValue?: SlotClass; } | undefined;
}

Slots

/**
 * Slots for the PricingTable component
 */
interface PricingTableSlots {
  caption(): any;
  tier(): any;
  tier-title(): any;
  tier-description(): any;
  tier-badge(): any;
  tier-button(): any;
  tier-billing(): any;
  tier-discount(): any;
  tier-price(): any;
  section-title(): any;
  feature-title(): any;
  feature-value(): any;
}

테마 (Theme)

export default defineAppConfig({
  ui: {
    pricingTable: {
      slots: {
        root: 'w-full relative',
        table: 'w-full table-fixed border-separate border-spacing-x-0 hidden md:table h-fit',
        list: 'md:hidden flex flex-col gap-6 w-full',
        item: 'p-6 flex flex-col border border-default rounded-lg',
        caption: 'sr-only',
        thead: '',
        tbody: '',
        tr: '',
        th: 'py-4 font-normal text-start border-b border-default',
        td: 'px-6 py-4 text-center border-b border-default',
        tier: 'p-6 text-start font-normal align-top h-full',
        tierWrapper: 'flex flex-col md:h-full',
        tierTitleWrapper: 'flex items-center gap-3',
        tierTitle: 'text-lg font-semibold text-highlighted',
        tierDescription: 'text-sm font-normal text-muted mt-1',
        tierBadge: 'truncate',
        tierPriceWrapper: 'flex items-center gap-1 mt-4',
        tierPrice: 'text-highlighted text-3xl sm:text-4xl font-semibold',
        tierDiscount: 'text-muted line-through text-xl sm:text-2xl',
        tierBilling: 'flex flex-col justify-between min-w-0',
        tierBillingPeriod: 'text-toned truncate text-xs font-medium',
        tierBillingCycle: 'text-muted truncate text-xs font-medium',
        tierButton: 'mt-6 md:mt-auto md:pt-6',
        tierFeatureIcon: 'size-5 shrink-0',
        section: 'mt-6 flex flex-col gap-2',
        sectionTitle: 'font-semibold text-sm text-highlighted',
        feature: 'flex items-center justify-between gap-1',
        featureTitle: 'text-sm text-default',
        featureValue: 'text-sm text-muted flex justify-center min-w-5'
      },
      variants: {
        section: {
          true: {
            tr: '*:pt-8'
          }
        },
        active: {
          true: {
            tierFeatureIcon: 'text-primary'
          }
        },
        highlight: {
          true: {
            tier: 'bg-elevated/50 border-x border-t border-default rounded-t-lg',
            td: 'bg-elevated/50 border-x border-default',
            item: 'bg-elevated/50'
          }
        }
      }
    }
  }
})

더 알아보기 (Learn more)