---
title: "Date Input · Ark UI — StyleX Blocks"
description: "Segmented date field with keyboard-editable month, day and year in locale order."
url: "https://stylexblocks.com/components/ark-ui/date-input/"
agent:
  instructions: "Use this search API to find relevant components and blocks across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://stylexblocks.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Date Input

Segmented date field with keyboard-editable month, day and year in locale order.

- Behavior engine: Ark UI
- Also available for: [Base UI](https://stylexblocks.com/components/base-ui/date-input.md), [UI SDK](https://stylexblocks.com/components/ui-sdk/date-input.md)
- Category: Form
- Variants: outline, subtle, flushed
- Sizes: xs, sm, md, lg, xl
- HTML page: https://stylexblocks.com/components/ark-ui/date-input/

## Install

Configure the project once (sets the behavior engine and import aliases):

```sh
npx stylexblocks init
```

Then add the item as source you own:

```sh
npx stylexblocks add date-input
```

Equivalent: `npx shadcn add @stylexblocks/date-input`. Registry item JSON: https://stylexblocks.com/r/ark-ui/date-input.json

## Usage

```tsx
import { DateInput, parseDate } from "#components/ui/ark-ui/date-input.tsx";
import { indigoPalette } from "@stylexblocks/ui/themes/palettes.ts";

export function Example() {
  return (
    // variant/size resolve once on Root; SegmentGroup renders the
    // locale-ordered month / day / year segments by default
    <DateInput.Root
      locale="en-US"
      defaultValue={[parseDate("2026-03-18")]}
      variant="outline"
      size="md"
      palette={indigoPalette}
    >
      <DateInput.Label>Start date</DateInput.Label>
      <DateInput.Control>
        <DateInput.SegmentGroup />
      </DateInput.Control>
      <DateInput.HiddenInput name="start" />
    </DateInput.Root>
  );
}

// controlled: <DateInput.Root value={value} onValueChange={(d) => setValue(d.value)}>
```

## Source

`components/ui/ark-ui/date-input.tsx`

```tsx
import {
  DateInput as ArkDateInput,
  useDateInputContext,
} from "@ark-ui/react/date-input";
import { createSlotRecipeContext } from "#lib/ark-ui/create-slot-recipe-context.tsx";
import { defineSlotRecipe } from "#lib/recipe-props.ts";
import * as stylex from "@stylexjs/stylex";
import { colorPalette } from '@stylexblocks/ui/color-palette.stylex.ts'
import { fontSizes } from '@stylexblocks/ui/tokens/font-sizes.stylex.ts'
import { fontWeights } from '@stylexblocks/ui/tokens/font-weights.stylex.ts'
import { lineHeights } from '@stylexblocks/ui/tokens/line-heights.stylex.ts'
import { semanticColors } from '@stylexblocks/ui/semantic-tokens/colors.stylex.ts'
import { semanticRadii } from '@stylexblocks/ui/semantic-tokens/radii.stylex.ts'
import { sizes } from '@stylexblocks/ui/tokens/sizes.stylex.ts'
import { spacing } from '@stylexblocks/ui/tokens/spacing.stylex.ts'

const dateInputRoot = stylex.create({
  base: {
    display: 'flex',
    flexDirection: 'column',
    gap: spacing._1_5,
    width: '100%',
  },
})

const dateInputLabel = stylex.create({
  base: {
    fontSize: fontSizes.sm,
    lineHeight: lineHeights.sm,
    fontWeight: fontWeights.medium,
    alignSelf: 'flex-start',
    userSelect: 'none',
    opacity: {
      default: null,
      ':is([data-disabled])': 0.5,
    },
  },
})

/** The input-shaped box the segments sit in; mirrors the `input` recipe. */
const dateInputControl = stylex.create({
  base: {
    display: 'flex',
    alignItems: 'center',
    width: '100%',
    minWidth: 0,
    position: 'relative',
    height: 'var(--input-height)',
    cursor: {
      default: 'text',
      ':is([data-disabled])': 'not-allowed',
    },
    color: semanticColors.fg,
    opacity: {
      default: null,
      ':is([data-disabled])': 0.5,
    },
    '--focus-color': colorPalette.focusRing,
    '--error-color': semanticColors.borderError,
    borderColor: {
      default: null,
      ':is([data-invalid], [aria-invalid="true"])': 'var(--error-color)',
    },
  },
})

const dateInputControlSizes = stylex.create({
  xs: {
    borderRadius: semanticRadii.control,
    paddingInline: spacing._2,
    '--input-height': sizes.controlXs,
    fontSize: fontSizes.xs,
    lineHeight: lineHeights.xs,
  },
  sm: {
    borderRadius: semanticRadii.control,
    paddingInline: spacing._2_5,
    '--input-height': sizes.controlSm,
    fontSize: fontSizes.sm,
    lineHeight: lineHeights.sm,
  },
  md: {
    borderRadius: semanticRadii.control,
    paddingInline: spacing._3,
    '--input-height': sizes.controlMd,
    fontSize: fontSizes.sm,
    lineHeight: lineHeights.sm,
  },
  lg: {
    borderRadius: semanticRadii.control,
    paddingInline: spacing._4_5,
    '--input-height': sizes.controlLg,
    fontSize: fontSizes.md,
    lineHeight: lineHeights.md,
  },
  xl: {
    borderRadius: semanticRadii.control,
    paddingInline: spacing._6,
    '--input-height': sizes.controlXl,
    fontSize: fontSizes.md,
    lineHeight: lineHeights.md,
  },
})

const dateInputControlVariants = stylex.create({
  outline: {
    backgroundColor: semanticColors.bg,
    borderWidth: '1px',
    borderStyle: 'solid',
    borderColor: {
      default: semanticColors.border,
      ':hover': semanticColors.borderEmphasized,
      ':is([data-invalid], [aria-invalid="true"])': 'var(--error-color)',
    },
    outlineWidth: {
      default: null,
      ':focus-within': 'var(--focus-ring-width, 1px)',
    },
    outlineOffset: {
      default: null,
      ':focus-within': '0px',
    },
    outlineStyle: {
      default: null,
      ':focus-within': 'solid',
    },
    outlineColor: {
      default: null,
      ':focus-within': 'var(--focus-color)',
    },
  },
  subtle: {
    backgroundColor: semanticColors.bgMuted,
    borderWidth: '1px',
    borderStyle: 'solid',
    borderColor: {
      default: 'transparent',
      ':is([data-invalid], [aria-invalid="true"])': 'var(--error-color)',
    },
    outlineWidth: {
      default: null,
      ':focus-within': 'var(--focus-ring-width, 1px)',
    },
    outlineOffset: {
      default: null,
      ':focus-within': '0px',
    },
    outlineStyle: {
      default: null,
      ':focus-within': 'solid',
    },
    outlineColor: {
      default: null,
      ':focus-within': 'var(--focus-color)',
    },
  },
  flushed: {
    backgroundColor: 'transparent',
    borderRadius: 0,
    paddingInline: 0,
    borderBottomWidth: '1px',
    borderBottomStyle: 'solid',
    borderBottomColor: {
      default: semanticColors.border,
      ':is([data-invalid], [aria-invalid="true"])': 'var(--error-color)',
      ':focus-within': 'var(--focus-color)',
    },
    boxShadow: {
      default: null,
      ':focus-within': '0px 1px 0px 0px var(--focus-color)',
    },
  },
})

const dateInputSegmentGroup = stylex.create({
  base: {
    display: 'inline-flex',
    alignItems: 'center',
    whiteSpace: 'nowrap',
    fontVariantNumeric: 'tabular-nums',
  },
})

const dateInputSegment = stylex.create({
  base: {
    display: 'inline-block',
    paddingInline: '1px',
    borderRadius: semanticRadii.l1,
    outline: 'none',
    textAlign: 'end',
    caretColor: 'transparent',
    userSelect: 'none',
    fontVariantNumeric: 'tabular-nums',
    color: {
      default: semanticColors.fg,
      ':is([data-placeholder-shown]):not(:focus)': semanticColors.fgMuted,
      ':is([data-type="literal"])': semanticColors.fgMuted,
      ':focus': colorPalette.contrast,
    },
    backgroundColor: {
      default: null,
      ':focus': colorPalette.solid,
    },
  },
})

export type DateInputSize = keyof typeof dateInputControlSizes

export type DateInputVariant = keyof typeof dateInputControlVariants

const dateInputRecipe = defineSlotRecipe({
  slots: {
    root: { styles: dateInputRoot },
    label: { styles: dateInputLabel },
    control: {
      styles: dateInputControl,
      sizes: dateInputControlSizes,
      variants: dateInputControlVariants,
    },
    segmentGroup: { styles: dateInputSegmentGroup },
    segment: { styles: dateInputSegment },
  },
  defaultVariants: { size: "md", variant: "outline" },
});

const { withProvider, withContext } = createSlotRecipeContext(dateInputRecipe);

const Segment = withContext(ArkDateInput.Segment, "segment", "DateInputSegment");

/** Renders the machine's locale-ordered segments when given no children. */
function SegmentGroupNode({
  children,
  ...props
}: React.ComponentProps<typeof ArkDateInput.SegmentGroup>) {
  const api = useDateInputContext();
  return (
    <ArkDateInput.SegmentGroup {...props}>
      {children ??
        api
          .getSegments({ index: props.index })
          .map((segment, i) => <Segment key={i} segment={segment} />)}
    </ArkDateInput.SegmentGroup>
  );
}

/**
 * DateInput — Ark UI's date-input machine: a segmented date field
 * (month / day / year spinbuttons in locale order; arrows increment, typed
 * digits auto-advance, Backspace clears) wearing the date-input slot recipe.
 * `<DateInput.Root variant size>` resolves the recipe once; every part
 * inherits it through context. Control is the input-shaped box; SegmentGroup
 * renders the segments by default. Values are `@internationalized/date`
 * `DateValue`s — build them with the re-exported `parseDate`.
 */
export const DateInput = {
  Root: withProvider(ArkDateInput.Root, "root", "DateInputRoot"),
  Label: withContext(ArkDateInput.Label, "label", "DateInputLabel"),
  Control: withContext(ArkDateInput.Control, "control", "DateInputControl"),
  SegmentGroup: withContext(SegmentGroupNode, "segmentGroup", "DateInputSegmentGroup"),
  Segment,
  HiddenInput: ArkDateInput.HiddenInput,
  Context: ArkDateInput.Context,
};

export { parseDate } from "@ark-ui/react/date-picker";
export type { DateInputDateValue as DateValue } from "@ark-ui/react/date-input";

export type DateInputRootProps = React.ComponentProps<typeof DateInput.Root>;
export type DateInputControlProps = React.ComponentProps<typeof DateInput.Control>;
export type DateInputSegmentProps = React.ComponentProps<typeof DateInput.Segment>;
```
