You are viewing a PR preview for PR #1506

Agriculture Design System
Beta
Design System for the Export Service

Date range picker

The Date range picker component allows users to select a range of dates via a calendar or text input.

View in FigmaView in StorybookView in Github
import { ... } from '@ag.ds-next/react/date-range-picker';

Usage

Date range picker components can be imported via the date-range-picker entrypoint in the @ag.ds-next/react package.

For example:

import { ... } from '@ag.ds-next/react/date-range-picker';

Props

DateRangePicker Props
PropTypeDescription
onChange(day: DateRange) => voidFunction to be fired following a change event.
valueDateRangeWithStringThe value of the field.
disabled?booleanIf true, the field will not be interactive.
fromInputRef?Ref<HTMLInputElement>Ref to the start input element.
fromInvalid?booleanDefault: "false"If true, the invalid state will be rendered for the start date.
fromLabel?stringDefault: "Start date"The label above the start date.
hideOptionalLabel?booleanIf true, "(optional)" will never be appended to the legend even when `required` is `false`.
hint?stringProvides extra information about the group of fields.
id?stringDefines an identifier (ID) which must be unique.
legend?stringDescribes the purpose of the group of fields.
maxDate?DateIf set, any days after this date will not be selectable.
message?stringMessage to show when the field is invalid.
minDate?DateIf set, any days before this date will not be selectable.
onFromInputChange?((inputValue: string) => void)Function to be fired when the input value is updated.
onToInputChange?((inputValue: string) => void)Function to be fired when the input value is updated.
required?booleanDefault: "false"If false, "(optional)" will not be appended to the legend.
toInputRef?Ref<HTMLInputElement>Ref to the end input element.
toInvalid?booleanDefault: "false"If true, the invalid state will be rendered for the end date.
toLabel?stringDefault: "End date"The label above the end date.
yearRange?{ from: number; to: number; }The range of options to display in calendar year select.

Source

You can view the full source code for this package on Github.