TimeInput
To select/input a time.
When To Use
By clicking the input box, you can select a time from a popup panel.
Basic
Click the input, and then we could select or input a time in panel.
astro
<label
class='block text-sm font-medium text-zinc-900 dark:text-zinc-100 mb-1'
for='t1'>Standard Time</label
>
<TimeInput id='t1' class='max-w-xs' /> With Seconds
Show seconds by enabling the showSeconds prop.
astro
<label
class='block text-sm font-medium text-zinc-900 dark:text-zinc-100 mb-1'
for='t2'>Detailed Time</label
>
<TimeInput id='t2' showSeconds={true} class='max-w-xs' /> Time Range
Enable range selection to pick a start and end time.
astro
<label
class='block text-sm font-medium text-zinc-900 dark:text-zinc-100 mb-1'
for='t3'>Time Range</label
>
<TimeInput id='t3' range={true} class='max-w-xs' /> Disabled
A disabled state of the time input.
astro
<label
class='block text-sm font-medium text-zinc-900 dark:text-zinc-100 mb-1'
for='t4'>Disabled</label
>
<TimeInput id='t4' disabled class='max-w-xs' /> 12 or 24 hours format
TimeInput can be forced to use 12 or 24 hour format using the hourCycle property.
astro
<label
class='block text-sm font-medium text-zinc-900 dark:text-zinc-100 mb-1'
for='t5'>12 Hours Cycle</label
>
<TimeInput id='t5' hourCycle={12} class='max-w-xs' />
<br />
<label
class='block text-sm font-medium text-zinc-900 dark:text-zinc-100 mb-1'
for='t6'>24 Hours Cycle</label
>
<TimeInput id='t6' hourCycle={24} class='max-w-xs' /> Error State
Add an error state to TimeInput, which could display a message.
Invalid time selected
astro
<label
class='block text-sm font-medium text-zinc-900 dark:text-zinc-100 mb-1'
for='t7'>Error State</label
>
<TimeInput id='t7' error="Invalid time selected" class='max-w-xs' /> Success State
Add a success state to TimeInput.
Time is valid!
astro
<label
class='block text-sm font-medium text-zinc-900 dark:text-zinc-100 mb-1'
for='t8'>Success State</label
>
<TimeInput id='t8' success="Time is valid!" class='max-w-xs' /> API
| Property | Description | Type | Default |
|---|---|---|---|
| label | Label for the time input | string | |
| showSeconds | Whether to show seconds in the picker | boolean | false |
| range | Enables time range selection | boolean | false |
| hourCycle | Forces 12 or 24 hour format (12 or 24) | '12' | '24' | |
| error | Error message to display | string | boolean | |
| success | Indicates a success state or displays a success message | string | boolean | |
| disabled | Whether the input is disabled | boolean | false |