Skip to main content
/
/
/
DatePicker

DatePicker

Input field for selecting a date

import DatePicker from "@intility/bifrost-react-datepicker";
<FormatDate> component to display a date
Props

This component is published as a separate package and uses react-datepicker under the hood. See props docs on github for full documentation.

Install package

  1. Run the following command to install:
Shell
npm install @intility/bifrost-react-datepicker
  1. Include datepicker.css globally, method may vary depending on your build system.
TypeScript
import "@intility/bifrost-react-datepicker/datepicker.css";
  1. Import component separately from other components
TSX
import DatePicker from "@intility/bifrost-react-datepicker";
  1. Use it in your JSX code
TSX
<DatePicker label="Select a date" />

Data binding

Bind data by using selected and onChange props.

Time selection

Using showTimeSelect prop will include time selection to the <DatePicker>. It shows a scrollable select and can be used with timeIntervals to set time intervals, default is 30. Add showTimeSelectOnly to hide date selection and calendar.

Avoid showTimeInput

Month / Year selection

Using showMonthYearPicker or showYearPicker prop will make the <DatePicker> pick month+year or year only.

Date range

More advanced use cases with preset buttons, duration formatting, and dropdown.

It's possible to select both start and end date in the same picker using endDate, startDate and selectsRange which makes the onChange callback receive an array with two values.

The swapRange prop allows the user to click either start or end date first.

Description

description prop can be used as hints or additional information.

Icon

rightIcon prop places the icon to the right.

Any font awesome icon can passed to the icon prop.

Small

Use small prop to decrease the input height from 40px to 32px.

Validation

DatePicker can have different states. Use feedback to provide additional information (provide a blank string to reserve space for it).

Use 'warning' when date value is missing or invalid. If user ignores the warning and tries to submit form, use 'alert'. Use 'success'for validated fields. Default state is 'default'.

Forms example usage demo

Locale

Wrap your app in <Bifrost> to configure locale for all bifrost components, including the DatePicker:

Configure locale for Bifrost components

Read only

Set the datepicker to read-only with readOnly prop.

Disabled

Disable the datepicker with disabled prop.

Clearable

Add a clear button to the input field with isClearable prop. (When a value is present)