TimePicker
A 12-hour format time picker with an AM/PM select.
import { TimePicker } from "phoundry-ui";Basic usage
Loading interactive example…
View source
<script lang="ts"> import { TimePicker } from "phoundry-ui";
let hour = $state(14);
let minute = $state(30);
function formatTime(h: number, m: number): string { const period = h >= 12 ? "PM" : "AM"; const h12 = h % 12 || 12; return `${h12}:${String(m).padStart(2, "0")} ${period}`; }</script>
<TimePicker bind:hour bind:minute /><p class="mt-2 text-xs text-txt-tertiary"> Selected: {formatTime(hour, minute)} ({hour}:{String(minute).padStart(2, "0")} 24h)</p>onchange callback
Loading interactive example…
View source
<script lang="ts"> import { TimePicker } from "phoundry-ui";
let hour = $state(14);
let minute = $state(30);
let dh = $state(9);
let dm = $state(0);
let log = $state("");</script>
<TimePicker bind:hour={dh} bind:minute={dm} onchange={(h: number, m: number) => { log = `${h}:${String(m).padStart(2, "0")}`; }}/><p class="mt-2 text-xs text-txt-tertiary"> Last callback: {log || "move a field"}</p>Disabled
Loading interactive example…
View source
<script lang="ts"> import { TimePicker } from "phoundry-ui";
let hour = $state(14);
let minute = $state(30);
let dh = $state(9);
let dm = $state(0);</script>
<TimePicker bind:hour={dh} bind:minute={dm} disabled />TimePicker props
From phoundry-ui@0.4.21
| Name | Type | Default | Description |
|---|---|---|---|
hourbindable | number | 0 | Hour value (0-23). |
minutebindable | number | 0 | Minute value (0-59). |
onchange | (hour: number, minute: number, second?: number | undefined) => void | — | Called when the time changes. |
disabled | boolean | false | Disable the inputs and select. |
class | string | '' | Additional CSS classes on the wrapper. |
Usage tips
- Use
bind:hourandbind:minuteto keep your state in sync with the picker. - The component automatically handles 12-hour to 24-hour conversion internally.
- The
hourprop is always a 24-hour value (0-23).
CSS styling
.ph-time-picker is the stable identification hook for TimePicker. Part selectors and --_ph-* properties are internal. Component CSS is scoped and unlayered; Consumer classes remain additive and utility overrides may lose precedence.
Clock and duration modes keep their value and callback contracts. Field widths and typography are owned by CSS; duration hours remain wider than minute/second fields.
Keep the shared component stylesheet and a named Theme imported. Decorative motion respects reduced-motion preferences.