부품 머리글·바닥글
머리 위 정보 줄 utility-bar
머리글 위 얇은 줄. 오늘 운영 상태('진료 중 · 18:30까지')와 짧은 안내, 작은 링크, 대표 전화를 한 줄에 둔다. 모바일에서는 상태와 전화만 남는다. hours 를 주면 운영 시간 부품(business-hours)으로 지금 상태를 계산한다.
설치
shadcn/ui 를 쓰는 Next.js 프로젝트에서 한 줄로 설치됩니다. 파일은 components/bpublish/utility-bar.tsx 로 들어오고, 공통 토큰(base)과 함께 쓰는 부품(business-hours)도 같이 설치됩니다. 테마는 테마에서 하나 고릅니다.
npx shadcn@latest add https://www.bpublish.com/r/utility-bar.json레지스트리를 등록했다면 npx shadcn@latest add @bpublish/utility-bar · 설치 안내
AI에게 맡기기
Claude Code, Cursor 같은 AI 코딩 도구에 붙여 넣으세요. MCP 서버를 연결해 두면 이름만 말해도 됩니다.
bpublish UI의 머리 위 정보 줄(utility-bar) 부품으로 만들어 줘. 설치: npx shadcn@latest add https://www.bpublish.com/r/utility-bar.json · 문서: https://www.bpublish.com/designs/components/utility-bar사용 예시
import { UtilityBar } from '@/components/bpublish/utility-bar'
import type { DayHours } from '@/components/bpublish/business-hours'
const week: DayHours[] = [
{},
{ open: '09:30', close: '18:30', breakTime: ['13:00', '14:00'] },
{ open: '09:30', close: '21:00', breakTime: ['13:00', '14:00'], night: true },
{ open: '09:30', close: '18:30', breakTime: ['13:00', '14:00'] },
{ open: '09:30', close: '21:00', breakTime: ['13:00', '14:00'], night: true },
{ open: '09:30', close: '18:30', breakTime: ['13:00', '14:00'] },
{ open: '09:30', close: '14:00' },
]
export default function Example() {
return (
<UtilityBar
statusLabel="오늘"
hours={{ week, term: '진료', closedTerm: '휴진', breakLabel: '점심시간' }}
info={[{ label: '야간 진료', value: '화 · 목 21:00까지' }]}
links={[
{ label: '비급여 진료비', href: '#fees' },
{ label: '오시는 길', href: '#location' },
]}
phone="031-000-0000"
/>
)
}속성
| 이름 | 형식 | 기본값 | 설명 |
|---|---|---|---|
phone필수 | string | — | 대표 전화 |
phoneLabel | string | '대표 전화' | 전화 앞 이름 (넓은 화면에서만) |
hours | OpenStatusProps | — | 운영 시간 { week, term, closedTerm, breakLabel, now, timeZone, closedDates }. 주면 지금 상태를 계산한다 |
status | ReactNode | — | hours 대신 직접 쓰는 상태 글 |
statusLabel | string | — | 상태 앞 작은 이름 (넓은 화면에서만) |
info | { label: string; value: string }[] | — | 짧은 안내 (큰 화면에서만) |
links | { label: string; href: string }[] | — | 작은 링크 (태블릿 이상) |
원본 코드
설치 명령 없이 그대로 복사해 넣어도 됩니다. React 외의 패키지는 쓰지 않습니다.
/**
* bpublish UI — 머리 위 정보 줄. https://www.bpublish.com/designs/components/utility-bar
* 머리글 위 얇은 줄. 오늘 운영 상태, 짧은 안내, 작은 링크, 대표 전화를 한 줄에 둔다.
* 모바일에서는 상태와 전화만 남는다. 상태는 hours 를 주면 운영 시간(business-hours)으로 계산한다.
*/
import type { ReactNode } from 'react'
import { OpenStatus, type OpenStatusProps } from './business-hours'
export type UtilityBarProps = {
/** 대표 전화 */
phone: string
phoneLabel?: string
/** 상태 앞의 작은 이름 (넓은 화면에서만) */
statusLabel?: string
/** 운영 시간. 주면 지금 상태를 계산해 보여 준다 ('진료 중 · 18:30까지') */
hours?: Omit<OpenStatusProps, 'className'>
/** hours 대신 직접 쓰는 상태 글 */
status?: ReactNode
/** 짧은 안내 (넓은 화면에서만). 예: 야간 진료 · 화 · 목 21:00까지 */
info?: { label: string; value: string }[]
/** 작은 링크 (넓은 화면에서만) */
links?: { label: string; href: string }[]
className?: string
}
export function UtilityBar({ phone, phoneLabel = '대표 전화', statusLabel, hours, status, info = [], links = [], className = '' }: UtilityBarProps) {
const state = status ?? (hours ? <OpenStatus {...hours} /> : null)
return (
<div className={`border-b border-border bg-muted text-[12.5px] text-muted-foreground ${className}`}>
<div className="shell flex h-9 items-center justify-between gap-4">
<p className="flex min-w-0 items-center gap-2.5">
{statusLabel && state ? <span className="hidden shrink-0 sm:inline">{statusLabel}</span> : null}
{state}
</p>
<div className="flex shrink-0 items-center gap-5">
{info.map((i) => (
<p key={i.label} className="hidden tabular-nums lg:block">
{i.label}
<span className="ml-2 text-foreground">{i.value}</span>
</p>
))}
{links.length ? (
<ul className="hidden items-center md:flex">
{links.map((l, i) => (
<li key={l.label} className={i > 0 ? 'border-l border-border pl-3 ml-3' : ''}>
<a href={l.href} className="transition-colors hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring">
{l.label}
</a>
</li>
))}
</ul>
) : null}
<a
href={`tel:${phone.replace(/[^0-9+]/g, '')}`}
className="font-medium text-foreground tabular-nums transition-colors hover:text-primary focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring"
>
<span className="mr-2 hidden font-normal text-muted-foreground sm:inline">{phoneLabel}</span>
{phone}
</a>
</div>
</div>
</div>
)
}