semantic-ui-calendar-react
Datepicker react component based on semantic-ui-react components
My intention was to create something that looks like this https://github.com/mdehoog/Semantic-UI-Calendar.
Here you can find a live example https://arfedulov.ru/examples/semantic-ui-calendar-react.
installation
npm i semantic-ui-calendar-react
Also you need to add css in your html:
<link rel="stylesheet" type="text/css" href="node_modules/semantic-ui-calendar-react/dist/css/calendar.min.css">
usage
Let's create a form that needs date-related input fields.
Import input components:
;
Then build a form:
Component { superprops; thisstate = date: '' time: '' dateTime: '' datesRange: '' ; } { if thisstate this; } { return <Form> <DateInput name="date" placeholder="Date" value=thisstatedate iconPosition="left" onChange=thishandleChange /> <TimeInput name="time" placeholder="Time" value=thisstatetime iconPosition="left" onChange=thishandleChange /> <DateTimeInput name="dateTime" placeholder="Date Time" value=thisstatedateTime iconPosition="left" onChange=thishandleChange /> <DatesRangeInput name="datesRange" placeholder="From - To" value=thisstatedatesRange iconPosition="left" onChange=thishandleChange /> </Form> ; }
Also you can build a form with inline pickers as inputs. Just set inline
prop on input element and it will be displayed as inline picker:
Component { if thisstate this; } { return <Form> <DateInput inline name="date" value=thisstatedate onChange=thishandleDateChange /> </Form> ; }
Locales support
Since semantic-ui-calendar-react
uses moment.js it has complete locales support.
To change locale you need to set moment
's locale in a scope that contains semantic-ui-calendar-react
components:
moment // code that uses ``semantic-ui-calendar-react`` components
Supported elements
DateInput
Prop | Description |
---|---|
all that can be used with SUIR Input | |
dateFormat |
{string} Date formatting string. You can use here anything that can be passed to moment().format . Default: DD-MM-YYYY |
popupPosition |
{string} One of ['top left', 'top right', 'bottom left', 'bottom right', 'right center', 'left center', 'top center', 'bottom center']. Default: top left |
inline |
{bool} If true inline picker displayed. Default: false |
startMode |
{string} Display mode to start. One of ['year', 'month', 'day']. Default: day |
TimeInput
Prop | Description |
---|---|
all that can be used with SUIR Input | |
popupPosition |
{string} One of ['top left', 'top right', 'bottom left', 'bottom right', 'right center', 'left center', 'top center', 'bottom center']. Default: top left |
inline |
{bool} If true inline picker displayed. Default: false |
DateTimeInput
Prop | Description |
---|---|
all that can be used with SUIR Input | |
dateFormat |
{string} Date formatting string. You can use here anything that can be passed to moment().format . Default: DD-MM-YYYY |
divider |
{string} Date and time divider. Default:
|
popupPosition |
{string} One of ['top left', 'top right', 'bottom left', 'bottom right', 'right center', 'left center', 'top center', 'bottom center']. Default: top left |
inline |
{bool} If true inline picker displayed. Default: false |
startMode |
{string} Display mode to start. One of ['year', 'month', 'day']. Default: day |
DatesRangeInput
Prop | Description |
---|---|
all that can be used with SUIR Input | |
dateFormat |
{string} Date formatting string. You can use here anything that can be passed to moment().format . Default: DD.MM.YY |
popupPosition |
{string} One of ['top left', 'top right', 'bottom left', 'bottom right', 'right center', 'left center', 'top center', 'bottom center']. Default: top left |
inline |
{bool} If true inline picker displayed. Default: false |
YearInput
Prop | Description |
---|---|
all that can be used with SUIR Input | |
popupPosition |
{string} One of ['top left', 'top right', 'bottom left', 'bottom right', 'right center', 'left center', 'top center', 'bottom center']. Default: top left |
inline |
{bool} If true inline picker displayed. Default: false |
MonthInput
Prop | Description |
---|---|
all that can be used with SUIR Input | |
popupPosition |
{string} One of ['top left', 'top right', 'bottom left', 'bottom right', 'right center', 'left center', 'top center', 'bottom center']. Default: top left |
inline |
{bool} If true inline picker displayed. Default: false |