---
title: "Timezone Picker · Ark UI — StyleX Blocks"
description: "Select-style timezone picker with a search input inside the panel — IANA zones and live offsets from Intl, filtered accessibly."
url: "https://stylexblocks.com/block/ark-ui/timezone-picker/"
agent:
  instructions: "Use this search API to find relevant components and blocks across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://stylexblocks.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Timezone Picker block

Select-style timezone picker with a search input inside the panel — IANA zones and live offsets from Intl, filtered accessibly.

- Behavior engine: Ark UI
- Also available for: [Base UI](https://stylexblocks.com/block/base-ui/timezone-picker.md), [UI SDK](https://stylexblocks.com/block/ui-sdk/timezone-picker.md)
- Category: [Pickers](https://stylexblocks.com/blocks/pickers.md)
- Built with: [Combobox](https://stylexblocks.com/components/ark-ui/combobox.md)
- HTML page: https://stylexblocks.com/block/ark-ui/timezone-picker/

## Install

Configure the project once (sets the behavior engine and import aliases):

```sh
npx stylexblocks init
```

Then add the item as source you own:

```sh
npx stylexblocks add timezone-picker
```

Equivalent: `npx shadcn add @stylexblocks/timezone-picker`. Registry item JSON: https://stylexblocks.com/r/ark-ui/timezone-picker.json

## Usage

```tsx
import { TimezonePicker } from "#components/blocks/ark-ui/timezone-picker.tsx";

export function Example() {
  return (
    <TimezonePicker
      name="timezone"
      defaultValue="Europe/Amsterdam"
      onValueChange={(zone) => {
        // IANA id, e.g. "Europe/Amsterdam"
      }}
    />
  );
}
```

## Source

`components/blocks/ark-ui/timezone-picker.tsx`

```tsx
import * as stylex from "@stylexjs/stylex";
import { useMemo, useState } from "react";
import { useListCollection } from "@ark-ui/react/collection";
import { useFilter } from "@ark-ui/react/locale";
import { Combobox, type ComboboxVariantProps } from "#components/ui/ark-ui/combobox.tsx";
import { semanticColors } from "@stylexblocks/ui/semantic-tokens/colors.stylex.ts";
import type { StyleOverrideProps } from "#lib/recipe-props.ts";

export interface Timezone {
  /** IANA zone id, e.g. "Europe/Amsterdam" — what your backend receives. */
  value: string;
  /** City part of the zone id, e.g. "Amsterdam". */
  label: string;
  /** Current UTC offset, e.g. "GMT+2" (DST-aware at render time). */
  offset: string;
  /** Offset in minutes, for sorting. */
  minutes: number;
}

/**
 * Every IANA timezone the runtime knows, with current offsets — no shipped
 * data to go stale. Sorted by offset, then name.
 */
export function getTimezones(): Timezone[] {
  const zones =
    typeof Intl.supportedValuesOf === "function" ? Intl.supportedValuesOf("timeZone") : ["UTC"];
  const now = new Date();
  return zones
    .map((zone) => {
      const parts = new Intl.DateTimeFormat("en-US", {
        timeZone: zone,
        timeZoneName: "shortOffset",
      }).formatToParts(now);
      const offset = parts.find((p) => p.type === "timeZoneName")?.value ?? "GMT";
      const m = offset.match(/GMT([+-])(\d{1,2})(?::(\d{2}))?/);
      const minutes = m ? (m[1] === "-" ? -1 : 1) * (Number(m[2]) * 60 + Number(m[3] ?? 0)) : 0;
      const label = zone.split("/").pop()!.replaceAll("_", " ");
      return { value: zone, label, offset, minutes };
    })
    .sort((a, b) => a.minutes - b.minutes || a.label.localeCompare(b.label));
}

const styles = stylex.create({
  offset: {
    color: semanticColors.fgSubtle,
    fontSize: "0.8125em",
    marginInlineStart: "auto",
    paddingInlineStart: "0.75rem",
  },
});

export interface TimezonePickerProps extends ComboboxVariantProps, StyleOverrideProps {
  label?: string;
  /** Trigger text while nothing is selected. */
  placeholder?: string;
  searchPlaceholder?: string;
  /** IANA zone id of the initial selection. */
  defaultValue?: string;
  /** IANA zone id of the controlled selection. */
  value?: string;
  onValueChange?: (zone: string) => void;
  /** Posts the selected zone id with native form submits via a hidden input. */
  name?: string;
  /** Override the offered zones, e.g. only your supported regions. */
  items?: Timezone[];
  disabled?: boolean;
}

/**
 * TimezonePicker — select-style trigger that opens a panel with a search
 * input above the list (the "select with filter" pattern). The whole thing
 * is one combobox machine, not a Select with an input bolted in: the panel
 * input carries the ARIA combobox wiring (aria-expanded, aria-controls,
 * aria-activedescendant), so filtering stays screen-reader-accessible.
 * Zones and offsets come from Intl at render time.
 */
export function TimezonePicker({
  label = "Timezone",
  placeholder = "Select timezone",
  searchPlaceholder = "Search timezones…",
  defaultValue,
  value,
  onValueChange,
  name,
  items,
  disabled,
  variant = "outline",
  size = "md",
  palette,
  style,
}: TimezonePickerProps) {
  const zones = useMemo(() => items ?? getTimezones(), [items]);
  const [inner, setInner] = useState(defaultValue ?? "");
  const selected = value ?? inner;
  const selectedZone = zones.find((z) => z.value === selected);

  const { contains } = useFilter({ sensitivity: "base" });
  const { collection, filter, reset } = useListCollection({
    initialItems: zones,
    itemToString: (z: Timezone) => `${z.label} (${z.offset})`,
    itemToValue: (z: Timezone) => z.value,
    // match the city name/offset, or anywhere in the IANA id ("europe/ams")
    filter: (itemText, filterText, item) =>
      contains(itemText, filterText) || contains(item.value, filterText),
  });

  return (
    <Combobox.Root
      collection={collection}
      defaultValue={defaultValue ? [defaultValue] : undefined}
      value={value !== undefined ? (value ? [value] : []) : undefined}
      onValueChange={(details) => {
        const zone = details.value[0] ?? "";
        setInner(zone);
        onValueChange?.(zone);
      }}
      onInputValueChange={(details) => filter(details.inputValue)}
      // the search is transient per open — a fresh panel shows every zone
      onOpenChange={(details) => {
        if (details.open) reset();
      }}
      selectionBehavior="clear"
      disabled={disabled}
      variant={variant}
      size={size}
      palette={palette}
      style={style}
    >
      <Combobox.Label>{label}</Combobox.Label>
      <Combobox.Control>
        <Combobox.FieldTrigger>
          <Combobox.FieldValue placeholder={placeholder}>
            {selectedZone ? `${selectedZone.label} (${selectedZone.offset})` : null}
          </Combobox.FieldValue>
        </Combobox.FieldTrigger>
      </Combobox.Control>
      <Combobox.Positioner>
        <Combobox.Panel>
          <Combobox.Search placeholder={searchPlaceholder} />
          <Combobox.PanelList>
            {collection.items.map((zone) => (
              <Combobox.Item key={zone.value} item={zone}>
                <Combobox.ItemText>{zone.label}</Combobox.ItemText>
                <span {...stylex.props(styles.offset)}>{zone.offset}</span>
                <Combobox.ItemIndicator />
              </Combobox.Item>
            ))}
            {collection.items.length === 0 ? (
              <Combobox.Empty>No timezones found</Combobox.Empty>
            ) : null}
          </Combobox.PanelList>
        </Combobox.Panel>
      </Combobox.Positioner>
      {name ? <input type="hidden" name={name} value={selected} /> : null}
    </Combobox.Root>
  );
}
```
