Skip to main content

DatePicker

Library
Allium Design Systemweb-only
Repository
github.com/telus/allium-design-system
Package
npmjs.com/package/@telus-uds/ds-allium
Package version
1.14.0
Loading...

Introduction

import { DatePicker } from '@telus-uds/ds-allium'

Use DatePicker to select a date on a calendar.

Guidance

  • Use overlay (default) variant to display in a modal container
  • Use overlay variant whenever possible as it is the most accessible solution; the input form field is type-accessible and optimized for mobile customers
  • Includes an input form field to allow manual key-in of dates
  • Opens the modal when the input form field receives focus
  • Width expands 100% until max-width of 340px

Uncontrolled component

warning

While DatePicker can be used as an uncontrolled component, using a ref to get the input's value behaves inconsistently between the default and inline version of the component. The inline version forwards the ref to a hidden input, but due to the limitations of the react-dates library, the default DatePicker attaches the ref to the component's wrapper.

It's recommended to use the onDateChange prop to get the current value of the input even when using it as an uncontrolled component. If you must rely on a ref to get the value on the input, you will need to find the input element nested inside the wrapper.

Loading...

Controlled component

If it is required that the state of the DatePicker be controlled by the application or other external methods, date and onDateChange props must be passed to the DatePicker.

Loading...

Accessibility

DatePicker has accessible controls and also uses the label prop to label the corresponding input.

Platform considerations

This component is currently only supported on web.

Props

NameTypeDefaultDescription
copy'en' | 'fr''en'Whether the English or French copy will be used (e.g. for accessibility labels).
datemomentPropTypes .momentObjundefinedA Moment instance representing the currently selected date, i.e. 'moment()'
feedbackstringundefinedA detailed description of validation error/success or additional instructions. Visual variant is determined based on the 'validation' prop.
hintstringundefinedA short description of the expected input.
hintPosition'inline' | 'below''inline'Position of the hint relative to label. Use 'below' to display a larger hint below the label.
id*stringA unique identifier.
inlineboolfalseA flag determining if the calendar picker is standalone or an input with overlay
isDayDisabledfuncundefinedA function determining whether a given date should be disabled @param {Moment} date The date to optionally disable @returns {bool}
labelstringundefinedThe field label to be displayed above the calendar
onDateChangefunc() => {}Event triggered every time a new date is clicked on @param {Moment} date The new date that was selected
tooltipstringundefinedContent of an optional 'Tooltip'. If set, a tooltip button will be shown next to the label.
validation'error' | 'success'undefinedUse to visually mark an input as valid or invalid.

Figma

Variants

Inline

  • Use Inline to display the DatePicker in a larger vieweable area; allows the customer to quickly and easily date availability
  • Does not include an input form field
  • Optimized for keyboard interaction and tablet touch
  • Recommended for viewports greater than or equal to 576px
Loading...

Feedback