Date Field
A Date Field takes a date typed in segments — day, month, year — with no calendar attached. Each segment validates on its own and can be stepped with the arrow keys, which makes it faster than a picker for a date somebody already knows.
Rendered live, with the same build of the library you install.
StartsType it, or step the segments with the arrow keys.
9192026
DateField.tsx
import { useState } from 'react';import { getLocalTimeZone, today } from '@internationalized/date';import { NDateField } from '@nayan-ui/react';const DateField = () => {const [value, setValue] = useState<any>(today(getLocalTimeZone()));return (<div><div className="max-w-sm"><NDateField label="Starts" value={value} onChange={setValue} helperText="Type it, or step the segments with the arrow keys." /></div></div>);};export default DateField;
| Name | Type | Default | Details |
|---|---|---|---|
| value | any | Optional | The value prop. |
| defaultValue | any | Optional | The defaultValue prop. |
| onChange | (value: any) => void | Optional | The onChange prop. |
| label | ReactNode | Optional | The label prop. |
| minValue | any | Optional | The minValue prop. |
| maxValue | any | Optional | The maxValue prop. |
| granularity | 'day' | 'hour' | 'minute' | 'second' | 'day' | The granularity prop. |
| disabled | boolean | false | The disabled prop. |
| isInvalid | boolean | false | The isInvalid prop. |
| variant | 'primary' | 'secondary' | 'primary' | The variant prop. |
| fullWidth | boolean | false | The fullWidth prop. |
| error | ReactNode | Optional | The error prop. |
| helperText | ReactNode | Optional | The helperText prop. |
| className | string | '' | The className prop. |
| labelClassName | string | '' | The labelClassName prop. |
| aria-label | string | 'Date' | The aria-label prop. |
Other components solving nearby problems.