Documentation
Form Components
Date Range Picker

Date Picker

The DatePicker component is a user-friendly and customizable calendar input designed for selecting a single date.

Installation

Install the package

npm i @start-base/react-form-elements

Add the styles

To use the React form elements styles in a Next.js project, import the styles in your layout.tsx file.

app/layout.tsx
import "@start-base/react-form-elements/styles.css";

Import the component

import DateRangePicker from '@start-base/react-form-elements/DateRangePicker';

Usages

API

This component combined with Calendar component and Select component. All props from Calendar component and Select can be passed to this component. The Calendar component is a wrapper around react-day-picker (opens in a new tab) DayPicker component. All props from DayPicker API Reference (opens in a new tab) can be passed to this component.

NameTypeDefaultDescription
namestringName of the input
labelstringnullLabel of the input
placeholderstringnullPlaceholder of the input
disableShrinkbooleanfalsePosition the label outside of the input
valuestring or numberValue of the input
onChangefunctionCallback function that is fired when the value changes.
inputClassNamestringnullClassname for input element
labelClassNamestringnullClassname for label element
errorClassNamestringnullClassname for error element
prependstring or elementnullPrepend text to the input
appendstring or elementnullAppend text to the input
appendClassNamestringnullClassname for append element
prependClassNamestringnullClassname for prepend element
disabledbooleanfalseDisable the input
errorstring or boolean or objectnullError message to display below the input. if value is a boolean input border will be change. Also you can pass schema validator error objects.
valueobject ""to - from object
localeobjectnulldate-fns locale object
formatstringMM/dd/yyyyDate format
calendarClassNamestringnullClassname for calendar element
numberOfMonthsnumber2Calender count to show date selection popup
separatorstring" / "Separator for dates on showing input

Styling