This browser is not supported. The glass needs a Chromium browser or Electron. Why

Pickers

Picker in its segmented, menu, navigation-link and wheel styles, DatePicker and ColorPicker: the SwiftUI pickers with their pop-ups, calendar, wheels and pushed option list.

import { ColorPicker, DatePicker, Picker, pickerDestination } from "@adamexu/glass";

Where they live

Pickers are rows of a Form or List inside a NavigationStack, as in SwiftUI. Two things set them up:

  • A navigation-link Picker pushes a value; give the stack a destination that tries pickerDestination(value) first.
  • Pop-ups, sheets and popovers go through PresentationRoot. Its idiom picks a phone's sheet or an iPad's popover, and window (the screen element's client rect, kept current on scroll and resize) and root (that element) keep them inside an embedded screen like the ones here. Without one they cover the browser window, and its width picks the idiom.

Picker

segmented is a SegmentedPicker; menu (and automatic) is the title and a menu button that opens the glass menu; navigationLink is a row with the selection and a chevron that pushes an inline-titled page of the options, a check on the selection, where picking another selects it and goes back; wheel is one column on a cylinder.

Vanilla, Chocolate, Strawberry
const destination = (value: unknown) => pickerDestination(value) ?? <NavigationPage title="Detail" />;

<PresentationRoot idiom="phone" window={screenRect} root={screen}>
  <NavigationStack
    destination={destination}
    root={
      <NavigationPage title="Pickers">
        <Form>
          <Section header="Segmented">
            <Picker title="Flavor" options={FLAVORS} selection={segment} onChange={setSegment} pickerStyle="segmented" />
          </Section>
          <Section header="Menu & Navigation">
            <Picker title="Menu Picker" options={FLAVORS} selection={menu} onChange={setMenu} pickerStyle="menu" />
            <Picker title="Navigation Picker" options={FLAVORS} selection={navigation} onChange={setNavigation} pickerStyle="navigationLink" />
          </Section>
          <Section header="Wheel">
            <Picker title="Flavor" options={FLAVORS} defaultSelection="Chocolate" pickerStyle="wheel" />
          </Section>
        </Form>
      </NavigationPage>
    }
  />
</PresentationRoot>

DatePicker

compact (the default) is the label and one or two pills; a pill pops up a glass panel with the calendar or a time wheel, growing from the pill on a spring. graphical is the month in place: swipe it or step it with the arrows, and the title opens month and year wheels; with dateAndTime a Time row and pill sit under it. wheel is the columns in place.

2026-06-09 09:41
const [date, setDate] = useState(() => new Date());

const destination = (value: unknown) => pickerDestination(value) ?? <NavigationPage title="Detail" />;

<PresentationRoot idiom="phone" window={screenRect} root={screen}>
  <NavigationStack
    destination={destination}
    root={
      <NavigationPage title="Pickers">
        <Form>
          <Section header="Date Picker">
            <DatePicker selection={date} onChange={setDate}>
              <Text>Date & Time</Text>
            </DatePicker>
            <DatePicker selection={date} onChange={setDate} displayedComponents="date" datePickerStyle="graphical">
              <Text>Calendar</Text>
            </DatePicker>
          </Section>
          <Section header="Wheels">
            <DatePicker selection={date} onChange={setDate} displayedComponents="hourAndMinute" datePickerStyle="wheel">
              <Text>Time</Text>
            </DatePicker>
          </Section>
        </Form>
      </NavigationPage>
    }
  />
</PresentationRoot>

"Today" is read from the clock; pass now to pin it. Names, column order, the first weekday and 12 or 24 hours come from locale, the browser's by default.

A wheel drags one to one with a finger or mouse past a 10 px gate and flings on lift; a tap on a row turns it there, and past an end it rubber-bands. A notched mouse wheel turns one row per notch; a trackpad follows and rests on the nearest row 120 ms after it stops.

ColorPicker

The label and a well (a swatch in a rainbow ring). The well opens a sheet on a phone and a popover beside it on an iPad, with Grid, Spectrum and Sliders tabs, opacity, saved colours and Chrome's eyedropper. onChange gives #RRGGBB (#RRGGBBAA when not opaque), or color(display-p3 ...) past sRGB.

color = "#0088FF"
const [color, setColor] = useState("#0088FF");

const destination = (value: unknown) => pickerDestination(value) ?? <NavigationPage title="Detail" />;

<PresentationRoot idiom="phone" window={screenRect} root={screen}>
  <NavigationStack
    destination={destination}
    root={
      <NavigationPage title="Pickers">
        <Form>
          <Section header="Color Picker">
            <ColorPicker selection={color} onChange={setColor}>
              <Text>Color</Text>
            </ColorPicker>
            <ColorPicker defaultSelection="#FF2D55" supportsOpacity={false}>
              <Text>No opacity</Text>
            </ColorPicker>
          </Section>
        </Form>
      </NavigationPage>
    }
  />
</PresentationRoot>

Props

Picker

PropTypeDefaultDescription
titlestring-Required. The row's label, the pushed page's title, the accessible name.
optionsstring[]-Required. The choices.
selectionstring-Controlled selection.
defaultSelectionstringthe first optionInitial selection when uncontrolled.
onChange(value: string) => void-Runs with the picked option.
pickerStyle"automatic" | "segmented" | "menu" | "navigationLink" | "wheel""automatic"automatic is menu.
disabledbooleanfalseStops responding.
tintstring-The menu style's button.

DatePicker

PropTypeDefaultDescription
childrenReactNode-The row's label (or pass label).
labelReactNode-The row's label, if not children.
selectionDate-Controlled date.
defaultSelectionDatenowInitial date when uncontrolled.
onChange(date: Date) => void-A day picked, a wheel come to rest.
displayedComponents"date" | "hourAndMinute" | "dateAndTime""dateAndTime"What it picks.
datePickerStyle"automatic" | "compact" | "graphical" | "wheel""automatic"automatic is compact. graphical with hourAndMinute draws compact.
in{ min?: Date; max?: Date }-The range; days and rows outside it read gray.
disabledbooleanfalseStops responding.
labelsHiddenbooleanfalseThe label isn't drawn.
localestringthe browser'sBCP 47: names, column order, first weekday, 12 or 24 hours.
nowDatetodayThe calendar's highlighted day.
tintstring-The accent: today, the open pill, the calendar's chevrons.
firstLayoutbooleanfalseOnly for comparing with an iOS capture: the graphical row as iOS first lays it out.
className, stylestring, CSSProperties-On the row.

ColorPicker

PropTypeDefaultDescription
childrenReactNode-The row's label; a string names the well.
selectionstring-"#RRGGBB", "#RRGGBBAA" or "color(display-p3 r g b / a)".
defaultSelectionstring"#0088FF"Initial colour when uncontrolled.
onChange(color: string) => void-"#RRGGBB" ("#RRGGBBAA" when not opaque), or color(display-p3 ...) past sRGB.
supportsOpacitybooleantrueShows the opacity track.
disabledbooleanfalseStops responding.
labelsHiddenbooleanfalseThe label isn't drawn.
className, stylestring, CSSProperties-On the row.

Building blocks

The pickers are made of three exported pieces, for a screen of your own: Calendar (the month grid with its paging, title wheels and keyboard), TimeWheel (hours, minutes and AM/PM in the locale's clock) and Wheel (any columns on a cylinder). Each is controlled.

Calendar

PropTypeDefaultDescription
selectionDate-Required. The selected day.
onChange(date: Date) => void-Required. A day picked.
todayDate-Required. The highlighted day.
localestring-Required. BCP 47.
layout"inline" | "popup" | "regular" | "duo""inline"A phone's row, the compact pop-up, an iPad's row, the Duo's outer panel.
min, maxDate-The range.
tintstring-The accent.
wheelBox{ x: number; y: number; width: number }-Where the month and year wheels sit.
footerReactNode-Under the grid.
styleCSSProperties-On the root.

TimeWheel

PropTypeDefaultDescription
valueDate-Required.
onChange(date: Date) => void-Required. A column came to rest.
localestring-Required. 12 or 24 hours, column order.
widthnumber-Required.
height, centernumber216, 107.833The wheel's height and where its axis is.
disabledbooleanfalseStops responding.

Wheel

PropTypeDefaultDescription
columnsWheelColumn[]-Required. Each column's id, position, width, alignment, row range, text and spoken value.
valuesRecord<string, number>-Required. Each column's row.
onChange(id: string, index: number, from: number) => void-Required. A column came to rest on a row.
onCommit() => void-While moving, what's under the band changed.
widthnumber-Required.
height, centernumber216, 107.833The wheel's height and where its axis is.
rownumber32Row pitch: 32 in a date picker, 30 in a Picker.
bandInsetnumber9The band's inset from the sides: none under a calendar's title.
fontSizenumber-One size for every row; a date picker's are 21 and 23.5 by default.
disabledbooleanfalseStops responding.
aria-label, stylestring, CSSProperties-On the role="group" root.

Keyboard and accessibility

  • A wheel column is a spinbutton: ArrowUp and ArrowDown step, PageUp and PageDown step five, Home and End go to the ends.
  • The calendar's days are a grid of gridcell buttons: arrows move a day or a week, Home and End go to the week's ends, PageUp and PageDown a month, Enter and Space pick.
  • A compact pill and the colour well have aria-haspopup="dialog" and aria-expanded; a tap outside or Escape closes the pop-up and focus goes back.

SwiftUI

SwiftUI@adamexu/glass
Picker(title, selection:) { }<Picker title options selection onChange>
.pickerStyle(.segmented / .menu / .navigationLink / .wheel)pickerStyle="segmented" / "menu" / "navigationLink" / "wheel"
.navigationDestination for a navigation-link Pickerdestination={(v) => pickerDestination(v) ?? ...}
DatePicker(title, selection:, in:, displayedComponents:)<DatePicker selection onChange in displayedComponents>title</DatePicker>
.datePickerStyle(.compact / .graphical / .wheel)datePickerStyle="compact" / "graphical" / "wheel"
displayedComponents: [.date, .hourAndMinute]displayedComponents="dateAndTime" (or "date", "hourAndMinute")
.environment(\.locale, Locale(identifier:))locale
ColorPicker(title, selection:, supportsOpacity:)<ColorPicker selection onChange supportsOpacity>title</ColorPicker>
.labelsHidden()labelsHidden