Edit hours and minutes in 24-hour time. Used for quiet hours and date filters.
Status: experimental · Components: TimeField
Import
Section titled “Import”import { TimeField } from 'nacre'import { signal } from 'nsh'import { TimeField } from 'nacre'
export function TimeFieldUsage() { const time = signal('09:30') return <TimeField testID="demo-time" accessibilityLabel="Start time" value={time()} onChange={time.set} />}Examples
Section titled “Examples”Disabled
Section titled “Disabled”Keeps the current value and skips keyboard focus.
Phone: Keeps the current time, dimmed and not editable.
import { TimeField } from 'nacre'
export function TimeFieldDisabled() { return <TimeField testID="demo-time-disabled" accessibilityLabel="End time" value="18:00" onChange={() => {}} disabled />}Keyboard
Section titled “Keyboard”| Key | Action |
|---|---|
| ← / → | Select the hour or minute segment |
| ↑ / ↓ | Adjust the selected segment |
Accessibility
Section titled “Accessibility”- Use accessibilityLabel to distinguish start and end times. The ring surrounds the field and a soft fill and inset stroke mark the active segment.
Do / Don’t
Section titled “Do / Don’t”Do
- Write the HH:mm value back in onChange
Don’t
- Use a minute field when only whole hours are available
Property descriptions follow the Chinese source comments.
TimeField
Section titled “TimeField”| Prop | Type | Default | Description |
|---|---|---|---|
value * |
string |
— | 24 小时制 HH:mm |
onChange * |
(value: string) => void |
— | |
accessibilityLabel * |
string |
— | |
disabled |
boolean |
— | |
testID |
string |
— |
* required