Socket
Socket
Sign inDemoInstall

rc-picker

Package Overview
Dependencies
20
Maintainers
6
Versions
292
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    rc-picker

React date & time picker


Version published
Weekly downloads
1M
decreased by-14.13%
Maintainers
6
Install size
1.93 MB
Created
Weekly downloads
 

Package description

What is rc-picker?

The rc-picker package is a React component library for date and time picking. It provides a set of components that allow users to select dates and times in a flexible and customizable manner. It supports a variety of formats and can be easily integrated into React applications.

What are rc-picker's main functionalities?

Date Selection

This feature allows users to select a date. The DatePicker component can be used to render a date input field, and it provides an onChange event to handle the selected value.

import React from 'react';
import DatePicker from 'rc-picker';

function App() {
  return (
    <DatePicker onChange={(value) => console.log(value)} />
  );
}

export default App;

Time Selection

This feature enables users to select a time. The TimePicker component, which is part of the rc-picker library, allows for time input with an onChange event to capture the time selected by the user.

import React from 'react';
import TimePicker from 'rc-picker/lib/TimePicker';

function App() {
  return (
    <TimePicker onChange={(value) => console.log(value)} />
  );
}

export default App;

Date Range Selection

This feature is for selecting a range of dates. The RangePicker component allows users to pick a start and end date, which is useful for defining periods like reservations or event durations.

import React from 'react';
import RangePicker from 'rc-picker/lib/RangePicker';

function App() {
  return (
    <RangePicker onChange={(values) => console.log(values)} />
  );
}

export default App;

Other packages similar to rc-picker

Readme

Source

rc-picker

NPM version build status Codecov npm download bundle size

Live Demo

https://react-component.github.io/picker/

Install

rc-picker

Usage

import Picker from 'rc-picker';
import 'rc-picker/assets/index.css';
import { render } from 'react-dom';

render(<Picker />, mountNode);

API

Picker

PropertyTypeDefaultDescription
prefixClsStringrc-pickerprefixCls of this component
classNameString''additional css class of root dom node
styleReact.CSSPropertiesadditional style of root dom node
dropdownClassNameString''additional className applied to dropdown
dropdownAlignObject:alignConfig of dom-alignvalue will be merged into placement's dropdownAlign config
popupStyleReact.CSSPropertiescustomize popup style
transitionNameString''css class for animation
localeObjectimport from 'rc-picker/lib/locale/en_US'rc-picker locale
inputReadOnlybooleanfalseset input to read only
allowClearboolean | { clearIcon?: ReactNode }falsewhether show clear button or customize clear button
autoFocusbooleanfalsewhether auto focus
showTimeboolean | ObjectshowTime optionsto provide an additional time selection
pickertime | date | week | month | yearcontrol which kind of panel should be shown
formatString | String[]depends on whether you set timePicker and your localeuse to format/parse date(without time) value to/from input. When an array is provided, all values are used for parsing and first value for display
use12Hoursbooleanfalse12 hours display mode
valuemomentcurrent value like input's value
defaultValuemomentdefaultValue like input's defaultValue
openbooleanfalsecurrent open state of picker. controlled prop
suffixIconReactNodeThe custom suffix icon
prevIconReactNodeThe custom prev icon
nextIconReactNodeThe custom next icon
superPrevIconReactNodeThe custom super prev icon
superNextIconReactNodeThe custom super next icon
disabledbooleanfalsewhether the picker is disabled
placeholderStringpicker input's placeholder
getPopupContainerfunction(trigger)to set the container of the floating layer, while the default is to create a div element in body
onChangeFunction(date: moment, dateString: string)a callback function, can be executed when the selected time is changing
onOpenChangeFunction(open:boolean)called when open/close picker
onFocus(event:React.FocusEvent<HTMLInputElement>) => voidcalled like input's on focus
onBlur(event:React.FocusEvent<HTMLInputElement>) => voidcalled like input's on blur
onKeyDown(event:React.KeyboardEvent<HTMLInputElement>, preventDefault: () => void) => voidinput on keydown event
directionString: ltr or rtlLayout direction of picker component, it supports RTL direction too.

PickerPanel

PropertyTypeDefaultDescription
prefixClsStringrc-pickerprefixCls of this component
classNameString''additional css class of root dom
styleReact.CSSPropertiesadditional style of root dom node
localeObjectimport from 'rc-picker/lib/locale/en_US'rc-picker locale
valuemomentcurrent value like input's value
defaultValuemomentdefaultValue like input's defaultValue
defaultPickerValuemomentSet default display picker view date
modetime | datetime | date | week | month | year | decadecontrol which kind of panel
pickertime | date | week | month | yearcontrol which kind of panel
tabIndexNumber0view tabIndex
showTimeboolean | ObjectshowTime optionsto provide an additional time selection
showTodaybooleanfalsewhether to show today button
disabledDateFunction(date:moment) => booleanwhether to disable select of current date
dateRenderFunction(currentDate:moment, today:moment) => React.Nodecustom rendering function for date cells
monthCellRenderFunction(currentDate:moment, locale:Locale) => React.NodeCustom month cell render method
renderExtraFooter(mode) => React.Nodeextra footer
onSelectFunction(date: moment)a callback function, can be executed when the selected time
onPanelChangeFunction(value: moment, mode)callback when picker panel mode is changed
onMouseDown(event:React.MouseEvent<HTMLInputElement>) => voidcallback when executed onMouseDown event
directionString: ltr or rtlLayout direction of picker component, it supports RTL direction too.

RangePicker

PropertyTypeDefaultDescription
prefixClsStringrc-pickerprefixCls of this component
classNameString''additional css class of root dom
styleReact.CSSPropertiesadditional style of root dom node
localeObjectimport from 'rc-picker/lib/locale/en_US'rc-picker locale
valuemomentcurrent value like input's value
defaultValuemomentdefaultValue like input's defaultValue
defaultPickerValuemomentSet default display picker view date
separatorString'~'set separator between inputs
pickertime | date | week | month | yearcontrol which kind of panel
placeholder[String, String]placeholder of date input
showTimeboolean | ObjectshowTime optionsto provide an additional time selection
showTime.defaultValue[moment, moment]to set default time of selected date
use12Hoursbooleanfalse12 hours display mode
disabledTimeFunction(date: moment, type:'start'|'end'):Object
ranges{ String | [range: string]: moment[] } | { [range: string]: () => moment[] }preseted ranges for quick selection
formatString | String[]depends on whether you set timePicker and your localeuse to format/parse date(without time) value to/from input. When an array is provided, all values are used for parsing and first value for display
allowEmpty[boolean, boolean]allow range picker clearing text
selectable[boolean, boolean]whether to selected picker
disabledbooleanfalsewhether the range picker is disabled
onChangeFunction(value:[moment], formatString: [string, string])a callback function, can be executed when the selected time is changing
onCalendarChangeFunction(value:[moment], formatString: [string, string], info: { range:'start'|'end' })a callback function, can be executed when the start time or the end time of the range is changing
directionString: ltr or rtlLayout direction of picker component, it supports RTL direction too.
orderbooleantrue(TimeRangePicker only) false to disable auto order

showTime-options

PropertyTypeDefaultDescription
formatStringmoment format
showHourbooleantruewhether show hour
showMinutebooleantruewhether show minute
showSecondbooleantruewhether show second
use12Hoursbooleanfalse12 hours display mode
hourStepNumber1interval between hours in picker
minuteStepNumber1interval between minutes in picker
secondStepNumber1interval between seconds in picker
hideDisabledOptionsbooleanfalsewhether hide disabled options
defaultValuemomentnulldefault initial value

Development

npm install
npm start

License

rc-picker is released under the MIT license.

Keywords

FAQs

Last updated on 25 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc