Skip to content

TimePicker

A 12-hour format time picker with an AM/PM select.

import { TimePicker } from "phoundry-ui";

Basic usage

Loading interactive example…

View source
basic-usage.svelte
<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
onchange-callback.svelte
<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
disabled.svelte
<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

NameTypeDefaultDescription
hourbindablenumber0Hour value (0-23).
minutebindablenumber0Minute value (0-59).
onchange(hour: number, minute: number, second?: number | undefined) => void—Called when the time changes.
disabledbooleanfalseDisable the inputs and select.
classstring''Additional CSS classes on the wrapper.

Usage tips

  • Use bind:hour and bind:minute to keep your state in sync with the picker.
  • The component automatically handles 12-hour to 24-hour conversion internally.
  • The hour prop 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.

Documentation is licensed under CC BY 4.0. Phoundry names and marks remain reserved.