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 requiredTimePickerAmPmLabelsAM/PM labels for the `12h` mode.
format required"12h" | "24h"
24h · 12h
24hClock display mode.
onChange required(value: string) => voidCalled with the pressed preset value.
presets requiredstring[] | TimePickerPresetGroup[]Flat `string[]` of times or labelled {@link TimePickerPresetGroup}s.
value requiredstringCurrently selected value in 24h format.
withSeconds requiredbooleanfalseWhether seconds are displayed.
getControlProps((value: string) => Partial<TimePresetControlProps>) | undefinedPasses props down to each preset cell, keyed by value (wins over `styles.control`).
maxHeightnumber | undefined200Max content height in px before it scrolls.
scrollAreaPropsScrollAreaProps | undefinedProps 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> | undefinedPer-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.

SlotUsage
controlstyles={{ control: { … } }}
gridstyles={{ grid: { … } }}
groupsstyles={{ groups: { … } }}
rootstyles={{ root: { … } }}