Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Business Hours

ProNew

Opening hours with a live Open or Closed status worked out in the business's timezone, from a one-line status to a full contact card.

Installation

pnpm dlx shadcn@latest add @viewport/business-hours

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above comes with Truffle Pro.

Props

PropTypeDefault
hours*WeekHours

Opening periods for each day, Sunday first.

—
timezonestring

IANA timezone of the business, such as `America/New_York`. Defaults to the visitor's own.

—
exceptionsHoursException[]

Holiday and one-off hours, replacing the week on their date.

—
layout"hours" | "compact" | "contacts" | "card" | "full"

`hours` is the status and the week; `compact` folds the week behind the status; `contacts` adds labelled contact rows; `card` and `full` add the photo, name and actions.

"hours"
namestring—
descriptionstring—
photostring

Cover photo for the `card` and `full` layouts.

—
logostring

Square logo shown above the name in the `full` layout.

—
phonestring—
addressstring—
addressHrefstring

Makes the address a link, for example to a map.

—
emailstring—
websitestring—
actionsBusinessAction[]

Buttons under the name in the `card` and `full` layouts.

[]
weekStart0 | 1

First day of the week: `0` for Sunday, `1` for Monday.

0
hour12boolean

12-hour times with AM and PM. Turn off for 24-hour times.

true
soonnumber

Minutes before closing when the status turns to "Closing soon".

30
defaultOpenboolean

Starts the folded week open in the `compact`, `contacts` and `card` layouts.

false
nowDate

Fixes the clock, for tests and screenshots. Defaults to the real time, checked every few seconds.

—
classNamestring—

Accessibility

  • The week is a real table with a caption; today's row is marked as the current date and reads “Today, Friday”.
  • The status is a live region, so “Closing soon” and “Closed” are announced when the time comes.
  • In the folded layouts the status is a button that says whether the week is expanded.
  • Phone, email and address are real links. The week unfolds without animation under reduced motion.