Skip to main content
Brand and assets
Build
Monitor and contribute
/
Component library
  • All components
  • Buttons & actions
  • Forms & inputs
    • Checkbox
    • ChoiceGroup
    • CurrencyInput
    • DateInput
    • FileInputZone
    • Filters
    • Form
    • MaskedTextInput
    • PasswordInput
    • Pill
    • Pill
    • Radio
    • SearchInput
    • SegmentedSlider
    • Select
    • Switch
    • TextArea
    • TextInput
  • Layout & containers
  • Overlays
  • Feedback & status
  • Data display
  • Typography
  • Accessibility
  • Contrib
  • Deprecated
  • Forms & inputs
  • DateInput

DateInput

Captures a date with the platform's native picker. Values are ISO date strings.

Health
Component health
Source
View on Github
Storybook
View in Storybook
Playground
No Example
Accessibility
unknown
Platform
Universal
  • Overview
  • Props

DateInput captures a date with the platform's native picker. value, defaultValue, min, max and onChange all use ISO date strings (YYYY-MM-DD).

It accepts the other TextInput props, except type and placeholder.

Usage​

Enter your date of birth

Controlled​

You can control the DateInput by providing value and onChange props. The value should be in ISO date format (YYYY-MM-DD):

import { useState } from "react";
import { DateInput } from "murray";

function Demo() {
const [value, setValue] = useState("2024-01-15");
return <DateInput value={value} onChange={(newValue) => setValue(newValue)} />;
}

Error state​

Like other form inputs, DateInput supports error states with boolean or string error messages:

Please enter a valid date

Disabled state​

Required field​

Use the required prop to mark the field as required, which adds a red asterisk to the label:

This field is required

Date range​

Use min and max to limit the selectable dates:

<DateInput label="Start date" min="2024-01-01" max="2024-12-31" />

Inline picker (iOS)​

On iOS, inline shows the spinner in place of the input. Other platforms ignore it.

<DateInput label="Start date" inline />

Prefix and suffix​

You can use prefix and suffix props to add icons or other elements to the left and right side of the input:

UTC

Condensed theme​

For applications with condensed theme density, this component renders in a condensed style:

Usage in <Form>​

On web, DateInput can be used in <Form> component and be controlled by Formik. This example shows date validation including age verification:

Select your preferred appointment date

You must be at least 18 years old

Date Format​

The DateInput component:

  • Input: Accepts ISO date strings (YYYY-MM-DD format)
  • Output: Always outputs ISO date strings or undefined
  • Display: Web uses the browser format, mobile shows DD/MM/YYYY

Platform Behavior​

  • Web: Renders as <input type="date"> with native browser date picker
  • iOS: Pressing the input opens a bottom sheet with a spinner and a confirm button, or the spinner shows in place with inline
  • Android: Pressing the input opens the native date picker dialog

Accessibility​

The DateInput component is fully accessible and includes:

  • Proper ARIA labels and descriptions
  • Keyboard navigation support
  • Screen reader compatibility
  • Native date picker accessibility features

Migration from DateInputDeprecated​

If you're migrating from DateInputDeprecated:

// Before (DateInputDeprecated)
<DateInputDeprecated
label="Date"
locale="en"
onChange={(value) => setValue(value)}
/>

// After (DateInput)
<DateInput
label="Date"
onChange={(value) => setValue(value)}
/>

Key differences:

  • No locale prop needed (uses native browser/OS locale)
  • No custom date formatting (uses ISO strings)
  • Simplified API with better platform integration

Playground​

Loading...
tip
This component is universal, its usage is the same in murray and murray/mobile.

DateInput props

NameTypeDefault ValueDescriptionUsage count
aria-describedbystringundefinedId of an element outside the input that also describes it, such as an error shared by several inputs
aria-labelstringundefinedAccessibility label, only necessary when not associated with a label
aria-labelledbystringundefined
aria-requiredbooleanundefinedOverrides `aria-required` set by `required`, to mark the input as mandatory without the asterisk
autoFocusbooleanundefinedIf true, focuses the input on componentDidMount.The default value is false.
cursorCursorundefinedEnforce a cursor type
defaultValuestringundefinedyyyy-MM-dd
disabledbooleanundefinedDisable input
enterKeyHint
6 possibilities"search""done""go""next""send"undefined
errorReactNodeContents of `InputError` component, if not set, error is not rendered.
focusedbooleanundefinedShow focus styles even when the input isn't focused, e.g. while a readonly input's picker is open
groupLabelReactNodeName of the group the input belongs to, such as the date its day field is part of. VoiceOver and TalkBack don't announce it when focus lands on the input, so on native it ends the input's accessible name, after `label`. Ignored without a `label`.
helpTextReactNodeContents of `InputHelp` component, if not set, description is not rendered.
idstringundefined
inlinebooleanundefinedRenders the picker in place instead of opening it from the input @platform ios
labelReactNode
maxstringundefinedLatest selectable date, yyyy-MM-dd
maxLengthnumberundefinedMaximum string length that the user can enter in UTF-16 code units
minstringundefinedEarliest selectable date, yyyy-MM-dd
minLengthnumberundefinedMaximum string length that the user can enter in UTF-16 code units @platform web
namestringundefinedHtml input name @platform web
onChange((value: string) => void)undefinedTrigger when input value is changing
onPress
2 possibilities((event: GestureResponderEvent) => void)undefined
prefixReactNodeContent section rendered on the left side of the input
prefixPointerEvents
5 possibilities"none""auto""box-none""box-only"undefined
Sets pointer-events styles on the `prefix` element, `none` by default
readonlybooleanundefinedMake input readonly
render
2 possibilities((elements: { input: ReactNode; prefix?: ReactNode; suffix?: ReactNode; }, pseudoState: PseudoState) => ReactNode)undefined
Fully control how input, prefix and suffix are rendererd
renderPlaceholder(() => ReactNode)undefinedTo render a custom placeholder view when the field is empty
requiredbooleanundefinedAdds required attribute to the input and a red asterisk on the right side of label, `false` by default Determines whether the input should have `aria-required` attribute
stepstringnumberundefined@platform web
suffixReactNodeContent section rendered on the right side of the input
suffixPointerEvents
5 possibilities"none""auto""box-none""box-only"undefined
Sets pointer-events styles on the `suffix` element, `none` by default
sxPositionPropsundefinedPositioning properties
titlestringundefinedHtml input title @platform web
valuestringundefinedyyyy-MM-dd

Undocumented props

NameTypeDefault ValueDescriptionUsage count
autoCompleteany
onBlurany
onSubmitEditingany
refany
testIDany

Style API​

Use sx for one-off adjustments. It accepts these style keys:

alignSelfanimationaspectRatiobottomcursordisplayendflexflexBasisflexGrowflexShrinkheightinsetinsetInlineinsetInlineEndinsetInlineStartleftmarginmarginBottommarginHorizontalmarginInlinemarginInlineEndmarginInlineStartmarginLeftmarginRightmarginTopmarginVerticalmatrixmaxHeightmaxWidthminHeightminWidthopacityperspectivepositionrightrotaterotateXrotateYrotateZscalescaleXscaleYskewXskewYstarttoptransformtransformOriginwidthxyzIndex

Each can be overridden per breakpoint with:

$lg$ltLg$ltMd$ltSm$ltVs$ltXl$ltXxl$md$sm$vs$xl$xs$xxl
Edit this page
Previous
CurrencyInput
Next
FileInputZone
  • Usage
  • Controlled
  • Error state
  • Disabled state
  • Required field
  • Date range
  • Inline picker (iOS)
  • Prefix and suffix
  • Condensed theme
  • Usage in <Form>
  • Date Format
  • Platform Behavior
  • Accessibility
  • Migration from DateInputDeprecated
  • Playground

Condensed theme