---
title: "Timezone Picker · UI SDK — 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/ui-sdk/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: UI SDK
- Also available for: [Ark UI](https://stylexblocks.com/block/ark-ui/timezone-picker.md), [Base UI](https://stylexblocks.com/block/base-ui/timezone-picker.md)
- Category: [Pickers](https://stylexblocks.com/blocks/pickers.md)
- Built with: [Combobox](https://stylexblocks.com/components/ui-sdk/combobox.md)
- HTML page: https://stylexblocks.com/block/ui-sdk/timezone-picker/

## Install

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

```sh
npx stylexblocks init --style ui-sdk
```

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/ui-sdk/timezone-picker.json

## Usage

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

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

## Source

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

```tsx
import * as stylex from "@stylexjs/stylex";
import { useMemo } from "react";
import {
  Combobox,
  type ComboboxSize,
  type ComboboxVariant,
} from "#components/ui/ui-sdk/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 StyleOverrideProps {
  variant?: ComboboxVariant;
  size?: ComboboxSize;
  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). UI SDK's
 * combobox supports this natively: the trigger opens the popup, focus moves
 * to the input inside it, and the 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 byId = useMemo(() => new Map(zones.map((zone) => [zone.value, zone])), [zones]);
  const labelOf = (id: string) => {
    const zone = byId.get(id);
    return zone ? `${zone.label} (${zone.offset})` : id;
  };

  return (
    <Combobox.Root
      // values are the IANA ids themselves; itemToLabel gives the trigger
      // its text before the list has ever rendered
      itemToLabel={labelOf}
      // match the city name/offset, or anywhere in the IANA id ("europe/ams")
      filter={(item, query) => {
        const zone = byId.get(String(item.value));
        if (!zone) return false;
        const q = query.toLowerCase();
        return (
          zone.label.toLowerCase().includes(q) ||
          zone.value.toLowerCase().includes(q) ||
          zone.offset.toLowerCase().includes(q)
        );
      }}
      defaultValue={defaultValue}
      value={value}
      onValueChange={(zone) => onValueChange?.(zone ?? "")}
      name={name}
      disabled={disabled}
      variant={variant}
      size={size}
      palette={palette}
      style={style}
    >
      <Combobox.Label>{label}</Combobox.Label>
      <Combobox.Control>
        <Combobox.FieldTrigger>
          <Combobox.FieldValue placeholder={placeholder}>
            {(zone) => (typeof zone === "string" ? labelOf(zone) : null)}
          </Combobox.FieldValue>
        </Combobox.FieldTrigger>
      </Combobox.Control>
      <Combobox.Panel>
        <Combobox.Search placeholder={searchPlaceholder} />
        <Combobox.PanelList>
          <Combobox.Empty>No timezones found</Combobox.Empty>
          <Combobox.List>
            {zones.map((zone) => (
              <Combobox.Item key={zone.value} value={zone.value} label={zone.label}>
                <Combobox.ItemText>{zone.label}</Combobox.ItemText>
                <span {...stylex.props(styles.offset)}>{zone.offset}</span>
                <Combobox.ItemIndicator />
              </Combobox.Item>
            ))}
          </Combobox.List>
        </Combobox.PanelList>
      </Combobox.Panel>
    </Combobox.Root>
  );
}
```
