Enable a React component (or group of components) to be selectable via mouse/touch.
npm i -S react-selectable-fast
Based on react-selectable
This project is based on react-selectable by unclecheese. The main idea of this fork is to eliminate render during selection caused by state updates of SelectableGroup. Only items under selectbox rerender themselves, which great for big lists of selectable items. Also, this package extends the original functionality with ability to scroll items while selecting relative to window and specified scroll container.
Package exports 5 entities
To make other components selectable wrap them using HoC
createSelectable, add passed
selectableRef prop to the target node and put a list of seletable items under
Object.assign) to be defined. If you support older browsers and
devices which may not yet provide these natively, consider including a global
polyfill in your bundled application, such as core-js or
A polyfilled environment for React-Selectable-Fast using core-js to support older browsers might look like this:
<SelectableGroup /> component accepts a few optional props:
duringSelection(Function) Callback fired rapidly during selection (while the selector is being dragged). Passes an array containing selectable items currently under the selector to the callback function.
enableDeselect(Boolean) Enables deselect with selectbox.
mixedDeselect(Boolean) When enabled items can be selected and deselected with selectbox at the same time,
enableDeselectshould be set to
scrollContainer(String) Selector of scroll container which will be used to calculate selectbox position. If not specified SelectableGroup element will be used as scroll container.
ignoreList(Array) Array of ignored selectors.
clickableClassName(String) On elements with specified selector click item containing this element will be selected.
tolerance(Number) The amount of buffer to add around your
<SelectableGroup />container, in pixels.
className(String) Class of selectable group element.
selectionModeClass(String) Class indicating that there is more than 1 selected item. Defaults to 'in-selection-mode'.
selectboxClassName(String) Class of selectbox element.
component(String) The component to render. Defaults to
allowClickWithoutSelected(Boolean) When disabled items can be selected by click only if there is more than 1 already selected item.
fixedPosition(Boolean) Whether the
<SelectableGroup />container is a fixed or absolutely positioned element or the grandchild of one.
resetOnStart(Boolean) Unselect all items when you start a new drag. Default value is
deselectOnEsc(Boolean) Unselect all items on ESC keydown/keyup events. Default value is
SelectableGroupgives access to
ref.clearSelection()method to unselect all items programmatically.
disabled(Boolean) Enable or disable the selectable draggable, useful if you want to enable drag of sub-items. Default value is
delta(Number) Value of the CSS transform property scaled list, useful if your list of items in
<SelectableGroup />is wrapped by a scale css transform property. Default value is
selectOnClick(Boolean) Allow selecting by clicking items. Default value is
allowAltClick(Boolean) Perform select actions even though the
altkey is down when clicking or dragging. Default value is
allowCtrlClick(Boolean) Perform select actions even though the
ctrlkey is down when clicking or dragging. Default value is
allowMetaClick(Boolean) Perform select actions even though the
metakey is down when clicking or dragging. Default value is
allowShiftClick(Boolean) Perform select actions even though the
shiftkey is down when clicking or dragging. Default value is