Dashral Pro is hereSee pricing

Dashral

Time Zone SelectNew

A time zone picker: offsets, cities and names in the reader's language, searchable.

$ pnpm dlx shadcn@latest add @dashral/time-zone-select

Reports and reminders use this time zone.

Installation

$ pnpm dlx shadcn@latest add @dashral/time-zone-select

Adds the component, the components it builds on, its npm packages and the theme tokens it uses. Or by its full URL: https://dashral.com/r/time-zone-select.json

Usage

example.tsx
import { TimeZoneSelect } from "@/components/dashral/time-zone-select"

<TimeZoneSelect label="Time zone" defaultValue="local" onValueChange={(zone) => saveSetting("timeZone", zone)} />

Using the npm package? Import from @dashral/ui/components/time-zone-select instead, here and in the examples; the rest is the same.

Examples

With the time there

The picked zone's time, live, beside it.

It's — there now.

Only some zones

timeZones limits the list to your offices.

API reference

TimeZoneSelect

Also takes every prop of Combobox(opens in a new tab).

PropTypeDefault
labelReactNode

Shown above, linked to the control.

—
descriptionReactNode

A hint under the control.

—
errorboolean | ReactNode

true shows the error style; a message also shows under the control.

—
labelActionReactNode

At the end of the label's row, e.g. a “Forgot password?” link or the current value.

—
withAsteriskboolean

Marks the label with an asterisk, e.g. alongside required.

false
valuestring

The time zone, an IANA name ("Asia/Jakarta"), controlled.

—
defaultValuestring | "local"

The first one; "local" for the reader's own, once the page has loaded.

—
onValueChange(value: string) => void

Called with the new value.

—
timeZonesstring[]

Only these.

every zone the browser knows
localestring

For the zones' names.

the LocaleProvider's
placeholder / searchPlaceholderstring

As on Combobox.

"Select a time zone" / "Search time zones…"
classNames{ root, label, description, error, trigger, content, item }

Classes for each part.

—
classNamestring

Extra classes, merged with cn() so yours win.

—

Keyboard

KeysAction
EnterorSpaceOpen the list
TypeSearch by city, region or name
↓or↑ and EnterPick one

Accessibility

  • With label, description or error, the id, aria-describedby and aria-invalid are wired up for you.
  • Each zone reads its offset and city ("GMT+07:00 Jakarta"), with its name in the page's language under it.