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 DatePicker component to a v7 DatePicker component.
date prop to value.onDateChange prop to onChange. See manual changes below.locale prop to lang.errorMessage prop to statusMessage.describedBy prop to aria-describedby.datesDescribedBy prop to aria-labelledby.placeholder prop exists, updates to showPlaceholder={true}. To customize the placeholder text, update the lang prop.accessibleHint prop exists, updates to hint and adds isHintVisuallyHidden={true}.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.buttonLabels.previousMonth prop to labelOverrides.previousMonthButtonScreenReaderLabel.buttonLabels.nextMonth prop to labelOverrides.nextMonthButtonScreenReaderLabel.buttonLabels.openCalendar prop. Use the labelOverrides.getCalendarButtonScreenReaderLabel prop instead.buttonLabels.closeCalendar prop. Use the labelOverrides.getCalendarButtonScreenReaderLabel prop instead.buttonLabels.getCalendarButtonScreenReaderLabel prop. Use the labelOverrides.getCalendarDayScreenReaderLabel prop instead.showLegend prop. If the circleDate or squareDate props are provided, then the legend will be shown.dateLabels.getPrimaryLabel prop. Use the circleDate.label prop instead.dateLabels.getSecondaryLabel prop. Use the squareDate.label prop instead.theme prop to the className prop. If it cannot, deletes the theme prop.For example:
import { DatePicker } from '@americanexpress/dls-react6';
export default function Page() {
return (
<DatePicker
id="date-picker-id"
date={date}
onDateChange={() => {}}
onBlur={() => {}}
locale="en-US"
errorMessage="Message."
describedBy="some-id"
datesDescribedBy="other-id"
placeholder="MM/DD/YYYY"
accessibleHint="Please select a date."
primaryDate={primaryDate}
secondaryDate={secondaryDate}
buttonLabels={{
previousMonth: 'Previous month',
nextMonth: 'Next month',
openCalendar: 'Open calendar',
closeCalendar: 'Close calendar',
selectedDate: 'Selected date',
}}
showLegend={true}
dateLabels={{ getPrimaryLabel, getSecondaryLabel }}
weekdays={weekdays}
format={format}
startDayOffset={startDayOffset}
theme={{ color: 'red' }}
{...otherProps}
/>
);
}
Transforms into:
import { DatePicker } from '@americanexpress/dls-react';
export default function Page() {
return (
<DatePicker
id="date-picker-id"
value={date}
onChange={() => {}}
onBlur={() => {}}
lang="en-US"
statusMessage="Message."
aria-describedby="some-id"
aria-labelledby="other-id"
showPlaceholder={true}
circleDate={{
dateString: primaryDate,
label: 'Primary Date',
}}
squareDate={{
dateString: secondaryDate,
label: 'Secondary Date',
}}
labelOverrides={{
previousMonthButtonScreenReaderLabel: 'Previous month',
nextMonthButtonScreenReaderLabel: 'Next month',
}}
weekdays={weekdays}
format={format}
startDayOffset={startDayOffset}
hint="Please select a date."
isHintVisuallyHidden={true}
{...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 onDateChange prop has been renamed to onChange and the function signature has been updated. The second parameter is an object whose key invalid has been renamed to isInvalid.
The onBlur function signature has been updated. The second parameter is an object whose key invalid has been renamed to isInvalid.
Connect with the DLS Team on Slack or by email.
Check out additional resources.