Back to Shark UI

Date Input

docs/components/date-input

latest7.8 KB
Original Source

Sections

Components

Utilities

Forms

Hooks

Date Input

Copy Markdown

Segmented input for dates and times.

DocsAPI

PreviewCode

mm/dd/yyyy

Installation#

CLIManual

pnpmbunnpmyarn

pnpm dlx shadcn@latest add @shark/date-input

Usage#

import { DateInput } from "@/components/ui/date-input";
<DateInput />

Controlled#

Use value and onValueChange to control the date input programmatically.

PreviewCode

mm/dd/yyyy

[]

States#

Disabled#

Use the disabled prop to prevent user interaction.

PreviewCode

mm/dd/yyyy

Invalid#

Use the invalid prop to indicate an error state.

PreviewCode

mm/dd/yyyy

Sizes#

Use the size prop to change the input height.

Small#

PreviewCode

mm/dd/yyyy

Medium#

PreviewCode

mm/dd/yyyy

Large#

PreviewCode

mm/dd/yyyy

Examples#

With Field#

Use Field components for a labeled date input with helper text.

PreviewCode

Date of birth

mm/dd/yyyy

Use your local date format.

Granularity#

Use the granularity prop to control which date fields are displayed.

PreviewCode

mm/dd/yyyy, ⁦––:––⁩ AM

Time Only#

PreviewCode

⁦––:––⁩ AM

Range#

Set selectionMode="range".

PreviewCode

mm/dd/yyyy

mm/dd/yyyy

Min and Max#

Use min and max to restrict the selectable date range.

PreviewCode

mm/dd/yyyy

Leading Zeros#

PreviewCode

mm/dd/yyyy

With Clear Button#

Use the showClear prop to display a clear button when the date input has a value.

PreviewCode

04/04/2024

Custom Separator#

PreviewCode

mm/dd/yyyy

mm/dd/yyyy

API Reference#

DateInput#

Root component for the date input.

PropTypeDefault
size`"sm""md"
showClearbooleanfalse
valueDateValue[]-
defaultValueDateValue[]-
onValueChange(details: ValueChangeDetails) => void-
selectionMode`"single""range"`
separator`stringReact.ReactNode`
granularity`"day""hour"
hourCycle`1224`
formatterDateFormatter-
minDateValue-
maxDateValue-
shouldForceLeadingZerosbooleantrue
disabledboolean-
invalidboolean-
classNamestring-

For additional props and behavior, see the Ark UI documentation.

[

Previous page

Data List ](/docs/components/data-list)[

Next page

Date Picker ](/docs/components/date-picker)

On This Page

InstallationUsageControlledStatesDisabledInvalidSizesSmallMediumLargeExamplesWith FieldGranularityTime OnlyRangeMin and MaxLeading ZerosWith Clear ButtonCustom SeparatorAPI ReferenceDateInput