Knit UI
GitHub

Playground

Loading playground…

false
Playground
<TimePresets
  presets={["08:00", "10:30", "12:00", "14:15", "18:00", "21:45"]}
  format="24h"
  amPmLabels={{ am: "AM", pm: "PM" }}
  withSeconds={false}
  maxHeight={200}
  size="sm"
/>

Examples

Default

A flat string[] with the active preset highlighted.

Loading example…

DefaultSourceStorybook

Grouped

Labelled groups (TimePickerPresetGroup[]).

Loading example…

GroupedSourceStorybook

Twelve Hour

12h formatting via the shared TimeValue.

Loading example…

Twelve HourSourceStorybook

Styled Slots

Per-slot styles sugar — recolour every preset cell via the control slot.

Loading example…

Styled SlotsSourceStorybook

Sizes

Every size token.

Loading example…

SizesSourceStorybook

Props

PropTypeDefaultDescription
amPmLabels requiredTimePickerAmPmLabels—AM/PM labels for the `12h` mode.
format required"12h" | "24h"
24h · 12h
24hClock display mode.
onChange required(value: string) => void—Called with the pressed preset value.
presets requiredstring[] | TimePickerPresetGroup[]—Flat `string[]` of times or labelled {@link TimePickerPresetGroup}s.
value requiredstring—Currently selected value in 24h format.
withSeconds requiredbooleanfalseWhether seconds are displayed.
getControlProps((value: string) => Partial<TimePresetControlProps>) | undefined—Passes props down to each preset cell, keyed by value (wins over `styles.control`).
maxHeightnumber | undefined200Max content height in px before it scrolls.
scrollAreaPropsScrollAreaProps | undefined—Props forwarded to the underlying `ScrollArea` (wins over `styles.root`).
size systemCalendarSize | undefined
xxs · xs · sm · md · lg · xl · xxl
'sm'Label font size.
styles systemSlotStyles<TimePresetsStyles> | undefined—Per-slot style sugar — props spread onto the matching styled part.

Style slots

Every part of TimePresets can be styled through the styles prop. Explicit props on the component always win over slot styles.

SlotTargets
controlProps for each preset cell (.Control — the TimePresetControl leaf).
gridProps for the flat grid (.Grid).
groupsProps for the grouped stack (.Groups).
rootProps for the scroll viewport (.Frame).

Edit this page on GitHub