부품 가게·기관 정보
요금표 price-table
묶음·항목·가격 열 여러 개(평일/주말/성수기 등)·보조 열·비고가 있는 요금표. 넓은 화면에서는 짙은 머리줄의 표, 모바일에서는 항목마다 한 덩이로 접혀 가로 스크롤 없이 읽힌다. 가격 열이 하나면(비급여 진료비 등) 항목 오른쪽에 금액이 붙는다.
설치
shadcn/ui 를 쓰는 Next.js 프로젝트에서 한 줄로 설치됩니다. 파일은 components/bpublish/price-table.tsx 로 들어오고, 공통 토큰(base)과 함께 쓰는 부품(section-head)도 같이 설치됩니다. 테마는 테마에서 하나 고릅니다.
npx shadcn@latest add https://www.bpublish.com/r/price-table.json레지스트리를 등록했다면 npx shadcn@latest add @bpublish/price-table · 설치 안내
AI에게 맡기기
Claude Code, Cursor 같은 AI 코딩 도구에 붙여 넣으세요. MCP 서버를 연결해 두면 이름만 말해도 됩니다.
bpublish UI의 요금표(price-table) 부품으로 만들어 줘. 설치: npx shadcn@latest add https://www.bpublish.com/r/price-table.json · 문서: https://www.bpublish.com/designs/components/price-table사용 예시
import { PriceTable } from '@/components/bpublish/price-table'
export default function Example() {
return (
<>
<PriceTable
title="요금표"
caption="객실별 1박 요금 (원)"
itemLabel="객실"
detailLabel="인원"
columns={[
{ key: 'weekday', label: '평일' },
{ key: 'weekend', label: '주말' },
{ key: 'peak', label: '성수기', accent: true },
]}
rows={[
{ name: '솔 텐트', sub: '6동', detail: '기준 2인 · 최대 4인', prices: { weekday: 129000, weekend: 169000, peak: 199000 } },
{ name: '숲 카라반', sub: '3동', detail: '기준 2인 · 최대 4인', prices: { weekday: 159000, weekend: 199000, peak: 239000 } },
{ name: '별채 오두막', sub: '2동', detail: '기준 4인 · 최대 6인', prices: { weekday: 219000, weekend: 269000, peak: 319000 } },
{ name: '가족 돔', sub: '1동', detail: '기준 4인 · 최대 6인', prices: { weekday: 199000, weekend: 249000, peak: 299000 } },
{ name: '추가 인원 1인', detail: '1박', value: 20000 },
]}
notes={['주말은 금·토요일과 공휴일 전날, 성수기는 7월 15일부터 8월 24일까지입니다.', '기준 인원을 넘으면 1인 1박에 20,000원이 더해지며, 24개월 미만 아기는 인원에 넣지 않습니다.']}
/>
<PriceTable
title="비급여 진료비 안내"
description="의료법 제45조에 따라 건강보험이 적용되지 않는 진료 항목의 비용을 알려 드립니다."
caption="비급여 진료비 안내"
detailLabel="기준"
unit=""
columns={[{ key: 'price', label: '금액 (원)' }]}
groups={[
{
name: '임플란트',
rows: [
{ name: '임플란트 (국산 픽스처)', detail: '1개, 보철 포함', prices: { price: 1100000 } },
{ name: '임플란트 (수입 픽스처)', detail: '1개, 보철 포함', prices: { price: 1600000 } },
{ name: '뼈 이식', detail: '1부위', prices: { price: '300,000 ~ 600,000' } },
],
},
{
name: '보철 · 충전',
rows: [
{ name: '지르코니아 크라운', detail: '1개', prices: { price: 550000 } },
{ name: '세라믹 인레이', detail: '1개', prices: { price: 350000 } },
{ name: '레진 충전', detail: '1면', prices: { price: '100,000 ~ 150,000' } },
],
},
]}
notes={['2026년 11월 기준 금액이며 부가가치세가 포함되어 있습니다.', '치아 상태와 재료에 따라 달라질 수 있으며, 진료 전에 정확한 비용을 먼저 안내해 드립니다.']}
/>
</>
)
}속성
| 이름 | 형식 | 기본값 | 설명 |
|---|---|---|---|
columns필수 | { key: string; label: string; accent?: boolean }[] | — | 가격 열. accent 는 강조색 |
caption필수 | string | — | 읽어 주는 표 이름 |
rows | { name; sub?; detail?; prices?: Record<string, number | string>; value?: number | string; note? }[] | — | 묶음 없는 줄. value 는 모든 가격 열을 한 칸으로 (추가 인원 등) |
groups | { name?: string; rows: PriceRow[] }[] | — | 묶음별 줄 |
title | string | — | 구역 제목 |
eyebrow | string | — | 제목 위 영문 소제목 |
description | string | — | 제목 옆 설명 |
itemLabel | string | '항목' | 첫 열 이름 |
detailLabel | string | — | 보조 열 이름. 주면 detail 이 열로 선다(없으면 이름 아래 작게) |
unit | string | '원' | 숫자 뒤 단위. 빈 글이면 붙이지 않는다 |
notes | string[] | — | 표 아래 안내 |
원본 코드
설치 명령 없이 그대로 복사해 넣어도 됩니다. React 외의 패키지는 쓰지 않습니다.
/**
* bpublish UI — 요금표. https://www.bpublish.com/designs/components/price-table
* 묶음·항목·가격 열 여러 개(평일/주말/성수기 등)·비고가 있는 요금표. 넓은 화면에서는 짙은 머리줄의 표,
* 모바일에서는 항목마다 한 덩이로 접혀 가로 스크롤 없이 읽힌다. 가격 열이 하나면 항목 오른쪽에 금액이 붙는다.
*/
import { Fragment } from 'react'
import { SectionHead } from './section-head'
export type PriceColumn = {
key: string
label: string
/** 강조색으로 (성수기 등 한 열만) */
accent?: boolean
}
export type PriceRow = {
name: string
/** 이름 옆 작은 말 (6동, 국산 …) */
sub?: string
/** 보조 열 값 (기준 2인 · 최대 4인, 1개 보철 포함 …) */
detail?: string
/** 열 key 별 가격. 숫자는 쉼표와 단위를 붙이고, 글은 그대로 쓴다 ('300,000 ~ 600,000') */
prices?: Record<string, number | string>
/** 모든 가격 열을 한 칸으로 쓰는 값 (추가 인원 등). 옅은 바탕 줄이 된다 */
value?: number | string
/** 이름 아래 작은 비고 */
note?: string
}
export type PriceGroup = { name?: string; rows: PriceRow[] }
export type PriceTableProps = {
columns: PriceColumn[]
/** 묶음 없이 줄만 */
rows?: PriceRow[]
/** 묶음 (임플란트, 보철 …) */
groups?: PriceGroup[]
/** 읽어 주는 표 이름 */
caption: string
title?: string
eyebrow?: string
description?: string
itemLabel?: string
/** 보조 열 이름. 주면 detail 이 열로 선다 */
detailLabel?: string
/** 숫자 뒤 단위. 빈 글이면 붙이지 않는다 */
unit?: string
/** 표 아래 안내 */
notes?: string[]
className?: string
}
const comma = (n: number) => String(n).replace(/\B(?=(\d{3})+(?!\d))/g, ',')
function Price({ v, unit }: { v: number | string | undefined; unit: string }) {
if (v == null || v === '') return <span className="text-muted-foreground">–</span>
if (typeof v === 'string') return <>{v}</>
return (
<>
{comma(v)}
{unit ? <span className="ml-0.5 text-[0.8em] font-medium">{unit}</span> : null}
</>
)
}
export function PriceTable({
columns,
rows,
groups,
caption,
title,
eyebrow,
description,
itemLabel = '항목',
detailLabel,
unit = '원',
notes = [],
className = '',
}: PriceTableProps) {
const list: PriceGroup[] = groups ?? [{ rows: rows ?? [] }]
const span = columns.length + 1 + (detailLabel ? 1 : 0)
const single = columns.length === 1
const mobileCols = Math.min(columns.length, 3)
return (
<section className={`py-16 md:py-24 ${className}`}>
<div className="shell">
{title ? <SectionHead title={title} eyebrow={eyebrow} description={description} className="mb-10 md:mb-12" /> : null}
{/* 넓은 화면: 표 */}
<div className="hidden overflow-hidden rounded-lg border border-border md:block">
<table className="w-full border-collapse text-left tabular-nums [&>tbody:last-child>tr:last-child]:border-b-0">
<caption className="sr-only">{caption}</caption>
<thead>
<tr className="bg-inverse text-sm text-inverse-foreground">
<th scope="col" className="px-6 py-3.5 font-semibold">
{itemLabel}
</th>
{detailLabel ? (
<th scope="col" className="px-4 py-3.5 font-semibold">
{detailLabel}
</th>
) : null}
{columns.map((c) => (
<th key={c.key} scope="col" className="px-6 py-3.5 text-right font-semibold">
{c.label}
</th>
))}
</tr>
</thead>
{list.map((g, gi) => (
<tbody key={g.name ?? gi}>
{g.name ? (
<tr className="border-b border-border bg-muted">
<th scope="colgroup" colSpan={span} className="px-6 py-3 text-[13.5px] font-semibold text-primary">
{g.name}
</th>
</tr>
) : null}
{g.rows.map((r) => (
<tr key={r.name} className={`border-b border-border ${r.value != null ? 'bg-muted' : 'bg-card'}`}>
<th scope="row" className="px-6 py-4 align-top font-medium">
<span className="text-base">{r.name}</span>
{r.sub ? <span className="ml-2 text-[13px] font-medium text-muted-foreground">{r.sub}</span> : null}
{!detailLabel && r.detail ? <span className="mt-0.5 block text-[13px] font-normal text-muted-foreground">{r.detail}</span> : null}
{r.note ? <span className="mt-1 block text-[13px] font-normal text-muted-foreground">{r.note}</span> : null}
</th>
{detailLabel ? <td className="px-4 py-4 align-top text-[14.5px] text-muted-foreground">{r.detail}</td> : null}
{r.value != null ? (
<td colSpan={columns.length} className="px-6 py-4 text-right align-top text-base font-semibold">
<Price v={r.value} unit={unit} />
</td>
) : (
columns.map((c) => (
<td key={c.key} className={`px-6 py-4 text-right align-top text-base font-semibold ${c.accent ? 'text-primary' : ''}`}>
<Price v={r.prices?.[c.key]} unit={unit} />
</td>
))
)}
</tr>
))}
</tbody>
))}
</table>
</div>
{/* 모바일: 항목마다 한 덩이 */}
<div className="overflow-hidden rounded-lg border border-border bg-card tabular-nums md:hidden" role="list" aria-label={caption}>
{list.map((g, gi) => (
<Fragment key={g.name ?? gi}>
{g.name ? <p className={`bg-muted px-5 py-2.5 text-[13px] font-semibold text-primary ${gi > 0 ? 'border-t border-border' : ''}`}>{g.name}</p> : null}
{g.rows.map((r, ri) => {
const line = ri > 0 || (gi > 0 && !g.name)
const head = (
<div className="min-w-0">
<p className="font-medium">
{r.name}
{r.sub ? <span className="ml-2 text-[13px] text-muted-foreground">{r.sub}</span> : null}
</p>
{r.detail ? <p className="mt-0.5 text-[13px] text-muted-foreground">{r.detail}</p> : null}
{r.note ? <p className="mt-0.5 text-[13px] text-muted-foreground">{r.note}</p> : null}
</div>
)
if (r.value != null || single) {
const v = r.value ?? r.prices?.[columns[0].key]
return (
<div key={r.name} role="listitem" className={`flex items-start justify-between gap-4 px-5 py-4 ${line ? 'border-t border-border' : ''} ${r.value != null ? 'bg-muted' : ''}`}>
{head}
<p className={`shrink-0 text-right font-semibold ${!r.value && columns[0].accent ? 'text-primary' : ''}`}>
<Price v={v} unit={unit} />
</p>
</div>
)
}
return (
<div key={r.name} role="listitem" className={`px-5 py-4 ${line ? 'border-t border-border' : ''}`}>
{head}
<dl className="mt-3 grid gap-x-3 gap-y-3 border-t border-border pt-3" style={{ gridTemplateColumns: `repeat(${mobileCols}, minmax(0, 1fr))` }}>
{columns.map((c) => (
<div key={c.key}>
<dt className="text-[12.5px] text-muted-foreground">{c.label}</dt>
<dd className={`mt-0.5 text-[17px] font-semibold tracking-[-0.01em] ${c.accent ? 'text-primary' : ''}`}>
<Price v={r.prices?.[c.key]} unit={unit} />
</dd>
</div>
))}
</dl>
</div>
)
})}
</Fragment>
))}
</div>
{notes.length ? (
<ul className="mt-6 max-w-3xl space-y-2 text-[13.5px] leading-[1.75] text-muted-foreground">
{notes.map((n) => (
<li key={n} className="flex gap-3">
<span aria-hidden className="mt-[11px] h-px w-3 shrink-0 bg-muted-foreground/60" />
{n}
</li>
))}
</ul>
) : null}
</div>
</section>
)
}