简体   繁体   English

禁用时将 TextField 的 borderBottom 样式更改为“无”?

[英]Change the borderBottom styling of the TextField, when disabled, to 'none'?

Within a datacell, I wasn't able to find out how to stack text.在数据单元中,我无法找到如何堆叠文本。 So I created a textfield, gave it value and gave it helper text and disabled the textfield and changed the text color to black when disabled.所以我创建了一个文本字段,给它赋值并给它辅助文本并禁用文本字段并在禁用时将文本颜色更改为黑色。 I've been trying to figure out how to change the bottomBorder to 'none' (which is what I assume is what is being used to create the dashed line under the input value text).我一直在试图弄清楚如何将 bottomBorder 更改为“无”(我认为这是用于在输入值文本下创建虚线的内容)。 This is what I have so far.这是我到目前为止。

const DarkerDisabledTextField = withStyles({
    root: {
        marginRight: 8,
        "& .MuiInputBase-root.Mui-disabled": {
            color: 'black',
            fontSize: '16px',
            borderBottom: 'none',

        }
    },
    underline: {
        "& .MuiInputBase-root.MuiInput-outlined": {

            borderBottom: 'none',

        }
    }
})(TextField);

This is what I used to create and style my textfield.这是我用来创建和设置文本字段样式的。 The underline key isn't working how I have read that it should.下划线键不起作用,我读过它应该。

And this is what I have tried so far with my textfield这就是我到目前为止用我的文本字段尝试过的

<DarkerDisabledTextField
    title={params.data.name}
    disabled
    defaultValue={params.data.name}
    helperText={title}
    fullWidth
 />

Within a datacell, I wasn't able to find out how to stack text.在数据单元中,我无法找到如何堆叠文本。 So I created a textfield, gave it value and gave it helper text and disabled the textfield and changed the text color to black when disabled.因此,我创建了一个文本字段,为其提供了值并为其提供了帮助文本,并禁用了该文本字段,并在禁用时将文本颜色更改为黑色。 I've been trying to figure out how to change the bottomBorder to 'none' (which is what I assume is what is being used to create the dashed line under the input value text).我一直在尝试找出如何将bottomBorder更改为“ none”(这是我所假设的是用于在输入值文本下创建虚线的内容)。 This is what I have so far.到目前为止,这就是我所拥有的。

const DarkerDisabledTextField = withStyles({
    root: {
        marginRight: 8,
        "& .MuiInputBase-root.Mui-disabled": {
            color: 'black',
            fontSize: '16px',
            borderBottom: 'none',

        }
    },
    underline: {
        "& .MuiInputBase-root.MuiInput-outlined": {

            borderBottom: 'none',

        }
    }
})(TextField);

This is what I used to create and style my textfield.这就是我用来创建和设置文本字段样式的内容。 The underline key isn't working how I have read that it should.下划线键不起作用,我已经读过它了。

And this is what I have tried so far with my textfield到目前为止,这是我在文本字段中尝试过的

<DarkerDisabledTextField
    title={params.data.name}
    disabled
    defaultValue={params.data.name}
    helperText={title}
    fullWidth
 />

if someone uses the Mui v5 inputs with createTheme , here's what i added to components :如果有人使用带有createTheme的 Mui v5 输入,这是我添加到components

createTheme({
    components: {
        MuiInputBase: {
            styleOverrides: {
                root: {
                    '&.MuiInput-root.Mui-disabled': {
                        ':before': {
                            borderBottomStyle: 'solid'
                        }
                    }
                }
            }
        }
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM