小编koo*_*ftr的帖子

如何风格化material-ui select

我需要制作 Material-ui 选择组件的风格化版本。我现在拥有的是:

import { Select } from '@material-ui/core';
import type { SelectProps } from '@material-ui/core';
import styled from 'styled-components';


const menuProps = {
    getContentAnchorEl: null,
    anchorOrigin: {
        vertical: "bottom",
        horizontal: "left",
    },

    PopoverClasses: {
        // pass only classnames
    }
}

const StyledSelect = styled(Select)<SelectProps>`
   ... some styles
`;

const Select: React.FC<SelectProps> = (props) => {
    return <StyledSelect MenuProps={menuProps} {...props}/>
};
Run Code Online (Sandbox Code Playgroud)

我需要将样式(不是类)传递给 Select 的弹出框部分,以在弹出框和输入之间留出边距。我尝试了一切并找到了向他们传递课程的唯一方法。但由于项目限制,我无法使用全局类或模块类,只能在js中传递。有任何想法吗? 所需更改的示例

reactjs material-ui styled-components

3
推荐指数
1
解决办法
2611
查看次数

标签 统计

material-ui ×1

reactjs ×1

styled-components ×1