538*_*MEO 4 javascript css disabled-input reactjs material-ui
我真的很难找到这个边框颜色的定义位置。我已经检查了 dom,但在任何输入组件及其伪元素中都没有看到边框样式......
我只是想减轻输入边框的颜色以匹配我的主题禁用颜色。
这是我使用的代码和渲染。
<OutlinedInput
size='small'
disabled={disabled}
value={value}
endAdornment={<InputAdornment position="end">{ctx.user.currency.short}</InputAdornment>}
inputProps={{ style: { paddingBottom: 4, } }}
style={{ fontWeight: 700, fontSize: 18 }}
{...props}
/>
Run Code Online (Sandbox Code Playgroud)
我尝试过使用<TextField />但它有同样的问题。请问你能帮帮我吗 ?
我是通过使用主题调色板来完成此操作的。我使用的是mui 5.5.0
import {createTheme} from "@mui/material";
const theme = createTheme({
palette: {
action: {
disabled: 'your color here e.g #000000',
}
},
});
Run Code Online (Sandbox Code Playgroud)
通过这样做,整个应用程序中的每个禁用字段都将具有调色板中定义的颜色。如果您想对单个/特定输入字段执行此操作,或者您想覆盖此调色板禁用的定义颜色。你可以通过以下方式做到这一点:
<TextField
value={value}
variant="outlined"
label="label"
disabled
sx={{
"& .MuiInputBase-root.Mui-disabled": {
"& > fieldset": {
borderColor: "your color here e.g #8cffcb"
}
}
}}
/>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9877 次 |
| 最近记录: |