Ard*_*lan 1 reactjs react-select
有没有办法增加菜单高度?我可以用属性来降低菜单的高度maxMenuHeight。但我找不到增加其高度的方法。我什至尝试过minMenuHeight财产,但那不起作用。这是我的代码以及自定义样式:
const defaultStyles = {
control: (base, state) => ({
...base,
}),
menu: base => ({
...base,
}),
menuList: base => ({
...base,
})
}
const customStyles = {
control: (base, state) => ({
...base,
background: "#000000",
// match with the menu
borderRadius: state.isFocused ? "3px 3px 0 0" : 3,
// Overwrittes the different states of border
// Removes weird border around container
boxShadow: state.isFocused ? null : null,
}),
menu: base => ({
...base,
// override border radius to match the box
borderRadius: 0,
backgroundColor: 'black',
// kill the gap
marginTop: 0
}),
menuList: base => ({
...base,
// kill the white space on first and last option
padding: 0
})
}
Run Code Online (Sandbox Code Playgroud)
<AsyncSelect
className="basic-single"
classNamePrefix="select"
loadOptions={loadOptions}
maxMenuHeight={500}
isMulti
styles={localStorage.getItem('theme') === 'dark' ? customStyles : defaultStyles}
cacheOptions
onChange={(e) => setSelect(e)}
defaultOptions />
Run Code Online (Sandbox Code Playgroud)
你可以用样式来做到这一点。
改变
menuList: base => ({
...base,
})
Run Code Online (Sandbox Code Playgroud)
和
menuList: base => ({
...base,
minHeight: "300px" // your desired height
})
Run Code Online (Sandbox Code Playgroud)
CodeSandbox的工作演示。
| 归档时间: |
|
| 查看次数: |
7184 次 |
| 最近记录: |