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

Click to Call

ProNew

A floating call bubble that opens a card with the agent's portrait, status, greeting and a tel: link.

Installation

pnpm dlx shadcn@latest add @viewport/click-to-call

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
phone*string

The number as people should read it, for example "+1 800-123-4567".

—
hrefstring

The link the number opens. Defaults to a `tel:` link built from the digits of `phone`.

—
namestring

The agent's name. Leave it out for a card with only a heading and the number.

—
rolestring

A line under the name, such as a job title.

—
avatarstring

Portrait URL. Initials are shown when it is missing or fails to load.

—
titlestring

A heading for cards without an agent, for example "Call us now".

—
messageReact.ReactNode

The greeting above the number.

—
onlineboolean

Whether someone is there to answer. Offline greys the status dot and shows `offlineNote`. Ignored when `hours` is given.

—
hoursWeekHours

Opening hours that decide `online` for you, in the business's `timezone`. While closed the widget follows `whenClosed`.

—
timezonestring

IANA timezone for `hours`. Defaults to the visitor's own.

—
exceptionsHoursException[]

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

—
whenClosed"offline" | "hide"

What happens outside `hours`: `offline` shows the card as offline with the next opening time, `hide` removes the widget entirely. Has no effect without `hours`.

"offline"
offlineNotestring

Shown under the number while offline.

"We are offline right now. Leave a voicemail and we will call back."
tone"auto" | "dark" | "accent"

Card surface: `auto` follows the theme, `dark` is always dark, `accent` fills the card with the accent color.

"auto"
accentstring

Color of the bubble and the number. Any CSS color that reads well under white text.

"#16a34a"
position"bottom-right" | "bottom-left"

Which bottom corner the bubble sits in.

"bottom-right"
fixedboolean

Pin to the viewport. Turn it off to place the widget inside the nearest positioned parent.

true
openboolean

Controlled open state.

—
defaultOpenboolean

Whether the card starts open when uncontrolled.

false
onOpenChange(open: boolean) => void

Called when the card opens or closes.

—
openAfternumber

Open the card by itself after this many milliseconds. Runs once.

—
pulseboolean

Rings around the closed bubble to draw the eye.

true
copyableboolean

Adds a button that copies the number, for devices that cannot place calls.

true
onCall() => void

Called when the number is pressed, for your own click tracking.

—
labelstring

Accessible name of the bubble.

"Call us"
classNamestring—

Accessibility

  • The bubble is a button with aria-expanded; the card is a labelled dialog that comes next in the tab order.
  • Escape closes the card and returns focus to the bubble.
  • The number is a real tel: link, with a copy button for devices that cannot dial.
  • Online or offline is stated in text for screen readers, not only by the dot color.
  • The pulse and the open animation are removed under reduced motion.