The American Express Design System provides a unified language for designing American Express websites and experiences. The design system provides design resources that match our coded components and are aligned with the American Express brand. Included are colors, components, icons and glyphs, type styles, and graphic assets to get you up and running quickly.
On this page
Converts a v6 DateRangePicker component to a v7 DateRangePicker component.
id prop which is required.canRetainEndDateOnChange prop to shouldRetainEndDateOnChange.errorMessage prop to statusMessage.locale prop to lang.placeholder prop exists, updates to showPlaceholder={true}. To customize the placeholder text, update the lang prop.primaryDate prop to circleDate.dateString. Use the circleDate.label prop to customize the label.secondaryDate prop to squareDate.dateString. Use the squareDate.label prop to customize the label.labels.previousMonth prop to labelOverrides.previousMonthButtonScreenReaderLabel.labels.nextMonth prop to labelOverrides.nextMonthButtonScreenReaderLabel.labels.openCalendar prop, which has been deprecated. Use the labelOverrides.getCalendarButtonScreenReaderLabel instead.labels.closeCalendar prop, which has been deprecated. Use the labelOverrides.getCalendarButtonScreenReaderLabel instead.labels.selectedDate prop, which has been deprecated.labels.accessibleHint prop, which has been deprecated. Use the hint prop instead.labels.getPrimaryLabel prop, which has been deprecated. Use circleDate.label prop instead.labels.getSecondaryLabel prop, which has been deprecated. Use squareDate.label prop instead.ids prop, which has been deprecated. Use the id prop instead.dates prop, which has been deprecated. See manual changes below.showLegend prop, which has been deprecated. If the circleDate or squareDate props are provided, then the legend will be shown.theme prop to the className prop. If it cannot, deletes the theme prop.For example:
import { DateRangePicker } from '@americanexpress/dls-react6';
export default function Page() {
return (
<DateRangePicker
ids={{ start: 'start-id', end: 'end-id' }}
dates={dates}
canRetainEndDateOnChange={true}
errorMessage="Message."
locale="en-US"
placeholder="MM/DD/YYYY"
primaryDate={primaryDate}
secondaryDate={secondaryDate}
labels={{
previousMonth: 'Previous month',
nextMonth: 'Next month',
openCalendar: 'Open calendar',
closeCalendar: 'Close calendar',
selectedDate: 'Selected date',
accessibleHint: 'Please select a date.',
getPrimaryLabel: () => {},
getSecondaryLabel: () => {},
}}
showLegend={true}
onChange={() => {}}
onBlur={() => {}}
weekdays={weekdays}
format={format}
startDayOffset={startDayOffset}
status={status}
theme={{ color: 'red' }}
{...otherProps}
/>
);
}
Transforms into:
import { DateRangePicker } from '@americanexpress/dls-react';
export default function Page() {
return (
<DateRangePicker
shouldRetainEndDateOnChange={true}
statusMessage="Message."
lang="en-US"
showPlaceholder={true}
circleDate={{
dateString: primaryDate,
label: 'Primary Date',
}}
squareDate={{
dateString: secondaryDate,
label: 'Secondary Date',
}}
labelOverrides={{
previousMonthButtonScreenReaderLabel: 'Previous month',
nextMonthButtonScreenReaderLabel: 'Next month',
}}
onChange={() => {}}
onBlur={() => {}}
weekdays={weekdays}
format={format}
startDayOffset={startDayOffset}
status={status}
id="unique-id-for-date-range-picker"
{...otherProps}
/>
);
}
dateStringThe expected format of the dateString (applicable to the new value, onChange, and onBlur props) across the board is now expected to always be in the format YYYY-MM-DD. If you were previously providing dateStrings to the component in a different format, please update your code to always provide and receive any dateStrings in the format YYYY-MM-DD.
The onChange and onBlur function signatures has been updated. The second argument is now an object of type:
{
start: { dateString: string, dateObject: Date | null },
end: { dateString: string, dateObject: Date | null },
isInvalid: boolean
}
dates prop is deprecatedMove the following v6 props to the corresponding v7 props:
dates.start -> value.startdates.end -> value.enddates.min -> minDatedates.max -> maxDatedates.disabled -> disabledDatesConnect with the DLS Team on Slack or by email.
Check out additional resources.