材料-UI:需要帮助隐藏下拉图标< select>
我正在使用 Material-ui 中的 Select 组件。在material-ui的文档中,据说您可以使用标签sx={{ ... }}覆盖组件中的CSS。我需要使用“.MuiSvgIcon-root-393”的 className 来设置组件的样式,它是“Select”的 SVG 子级,并且是下拉图标。这是我的尝试,但不起作用:
import { Select } from '@material-ui/core'
<Select
sx={{
'.MuiSvgIcon-root-393': {
visibility: 'hidden'
}
}}
>
....
<Select/>
我真正想做的是隐藏“选择”箭头。
我希望得到一些有关如何继续此操作的帮助和/或任何提示。
I am using the Select component from material-ui. In the documentation of material-ui, it is said that you can override the CSS from the components using the tag sx={{ ... }}. I need to style the component with className of '.MuiSvgIcon-root-393', which is a SVG child of 'Select', and is the dropdown icon. Here is my attempt, but is not working:
import { Select } from '@material-ui/core'
<Select
sx={{
'.MuiSvgIcon-root-393': {
visibility: 'hidden'
}
}}
>
....
<Select/>
What I am really trying to do is to make the Select arrow hidden.
I would appreciate some help in how to proceed with this, and/or any tips.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
认为这将解决您的问题。
github.com/mui/mui/material-ui/sissues/sissues/26473 只需删除图标,然后调整填充以收回将要占用的空间即可。
Think this will solve your problem.
github.com/mui/material-ui/issues/26473
Looks like they just remove the icon, and adjust the padding to reclaim the space it would've taken up.
根据条件,我只是将“跨度”作为ICONCOMPONENT的组成部分,这是这样的:
I am just passing "span" as component to IconComponent depending on condition, something like this:
在选择 sx 中使用
svg: {display:"none"}
这应该隐藏向下箭头图标
In Select sx use
svg: {display:"none"}
This should hide the arrow down icon
传递
popupIcon={null}
足以满足的要求。
组件。对于其他人来说可能都是一样的。Passing
popupIcon={null}
was enough for<Autocomplete/>
component. It might be all the same for others.