# Time picker

A field for choosing a time of day from a list.

```tsx
import { TimePickerField } from '@halo-ds/react';
```

## When to use it
Time input is a Select with a clock icon; its list shows times at a fixed step, like every 30 minutes. Time field adds a label and hint. Pair it with a Date field when people pick a day and a time, like a meeting or a delivery slot.

## Do
- Pick a step that fits the task, like 15 or 30 minutes.
- Use min and max to leave out times that can't be booked.
- Follow the region for 12 or 24 hours.
- Pair it with a Date field when the day matters too.

## Don't
- List every minute of the day; the list gets too long to scan.
- Use it for a length of time, like 1 hour 30 minutes; use a Number input.
- Mix 12 and 24 hours on one screen.
- Hide the time zone when people are in different ones.

## Props
### TimePickerField props
| Prop | Type | What it does |
| --- | --- | --- |
| `fieldClassName` | `string \| undefined` |  |
| `fieldClassNames` | `Partial<Record<FieldPart, string>> \| undefined` |  |
| `fieldStyles` | `Partial<Record<FieldPart, CSSProperties>> \| undefined` |  |
| `defaultValue` | `string \| undefined` |  |
| `className` | `string \| undefined` |  |
| `id` | `string \| undefined` |  |
| `aria-label` | `string \| undefined` |  |
| `name` | `string \| undefined` | Form field name. A hidden input carries the value. |
| `max` | `string \| undefined` |  |
| `min` | `string \| undefined` | Earliest and latest times offered, as "HH:mm". |
| `classNames` | `Partial<Record<SelectPart, string>> \| undefined` | Extra class names for the parts inside the component, by part name, like `{ header: 'my-header' }`. |
| `styles` | `Partial<Record<SelectPart, CSSProperties>> \| undefined` | Inline styles for the parts inside the component, by part name, like `{ footer: { gap: 4 } }`. |
| `size` | `"sm" \| "md" \| "lg" \| undefined` | 32, 40 or 48px. Figma: Size. |
| `disabled` | `boolean \| undefined` |  |
| `placeholder` | `string \| undefined` |  |
| `required` | `boolean \| undefined` |  |
| `step` | `number \| undefined` | Minutes between options. Default 30. |
| `value` | `string \| undefined` | The time as "HH:mm", 24-hour, like a native time input. |
| `invalid` | `boolean \| undefined` |  |
| `onValueChange` | `((value: string) => void) \| undefined` |  |
| `hourCycle` | `24 \| 12 \| undefined` | How times read in the list and the box. The value is always "HH:mm". |
| `label` | `ReactNode` |  |
| `error` | `ReactNode` | An error message. Replaces the hint, turns red and marks the control invalid. The control shows the warning icon, so the message has none. Figma: State=Error. |
| `hint` | `ReactNode` | Help text under the control. Figma: Hint. |
| `optional` | `boolean \| undefined` |  |
| `info` | `ReactNode` |  |
It also takes the usual HTML attributes for its element.

## Examples
### Overview
```tsx
import { TimePickerField } from '@halo-ds/react';

export default function Example() {
  return (
    <div style={{ width: 280 }}>
      <TimePickerField label="Start time" min="08:00" max="18:00" defaultValue="09:30" />
    </div>
  );
}
```

### Sizes
Small, medium and large.
```tsx
import { TimePickerField } from '@halo-ds/react';

export default function Demo() {
  return (
    <div className="demo-stack" style={{ width: 260 }}>
      <TimePickerField label="Small" size="sm" defaultValue="09:00" />
      <TimePickerField label="Medium" size="md" defaultValue="09:00" />
      <TimePickerField label="Large" size="lg" defaultValue="09:00" />
    </div>
  );
}
```

### Office hours
Every 15 minutes between 08:00 and 18:00, in 24-hour time.
```tsx
import { TimePickerField } from '@halo-ds/react';

export default function Demo() {
  return (
    <div style={{ width: 260 }}>
      <TimePickerField label="Meeting time" step={15} hourCycle={24} min="08:00" max="18:00" defaultValue="14:15" />
    </div>
  );
}
```

More: https://halodesignsystem.dev/components/time-picker
