Gathering detailed insights and metrics for @simplero/react-windowed-select
Gathering detailed insights and metrics for @simplero/react-windowed-select
Gathering detailed insights and metrics for @simplero/react-windowed-select
Gathering detailed insights and metrics for @simplero/react-windowed-select
npm install @simplero/react-windowed-select
Typescript
Module System
Node Version
NPM Version
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
6
29
An integration of react-window
with react-select
to efficiently render large lists.
The easiest way to use react-windowed-select
is to install it from npm:
npm install react-windowed-select
Then use it in your app:
1import React from "react"; 2import WindowedSelect from "react-windowed-select"; 3 4const options = []; 5 6for (let i = 0; i < 10000; i += 1) { 7 options.push({ 8 label: `Option ${i}`, 9 value: i 10 }); 11} 12 13function App () { 14 return <WindowedSelect options={options} />; 15}
For more examples, check out the Storybook.
react-windowed-select
is just a wrapper around react-select
.
All props passed to the WindowedSelect
component are forwarded to the default exported Select
component
from react-select
.
The number of options beyond which the menu will be windowed.
All of the named exports from react-select
are re-exported from react-windowed-select
for easy access to features
that allow you to customize your Select component.
1import { components, createFilter } from 'react-windowed-select'; 2import React from "react"; 3 4const options = [ 5 { value: 1, label: 'Foo' }, 6 { value: 2, label: 'Bar '}, 7]; 8 9const customFilter = createFilter({ ignoreAccents: false }); 10const customComponents = { 11 ClearIndicator: (props) => <components.ClearIndicator {...props}>clear</components.ClearIndicator> 12}; 13 14function App () { 15 return ( 16 <WindowedSelect 17 components={customComponents} 18 isClearable={true} 19 filterOption={customFilter} 20 options={options} 21 /> 22 ); 23}
By default, react-windowed-select
wraps the standard Select component from react-select
.
If you want to add windowing to the Async or Creatable Select components from react-select
, use the WindowedMenuList
:
1import { WindowedMenuList } from 'react-windowed-select'; 2import CreatableSelect from 'react-select/creatable'; 3 4function App () { 5 return ( 6 <CreatableSelect 7 components={{ MenuList: WindowedMenuList }} 8 // ...other props 9 /> 10 ); 11}
You can still use the styles API from react-select
to customize how your Select component looks.
The height property of the Option
, GroupHeading
, NoOptionsMessage
and/or LoadingMessage
components is used to determine the total height of the windowed menu and the following defaults are provided:
Component | Default Height |
---|---|
Option | 35px |
GroupHeading | 25px |
NoOptionsMessage | 35px |
LoadingMessage | 35px |
To override these values, use the styles
prop like you would with a regular react-select
component.
1<WindowedSelect 2 options={options} 3 styles={{ 4 option: (base) => ({ 5 ...base, 6 height: 60, // must be type number 7 padding: '20px 12px', 8 }), 9 }} 10/>
Grouped options are not fully supported.
In order to ensure proper scrolling and focus behavior, options nested inside the Group
component are flattened. This changes the component structure within MenuList
in the following way:
MenuList
│
└───Group
│ │
| └───GroupHeading
|
└───Option 1
|
└───Option 2
No vulnerabilities found.
No security vulnerabilities found.