我在我的 React 应用程序中使用私有引导程序 css 样式。我想用引导程序样式更新默认材质 ui 组件的样式。
import React, {useState} from 'react';
import 'cg-bootstrap/core/build/cg-bootstrap-standard.css'
const Sample = () => {
const [value, setValue]= useState('');
const handleChange = (e:React.ChangeEvent<HTMLInputElement> ) => {
setValue(e.target.value);
}
return (
<Grid container justify="center" alignItems="center">
<Grid item>
<Typography>Label text</Typogrpahy>
</Grid>
<Grid item>
<TextField value={state.value} variant="contained" onChange={handleChange}/>
</Grid>
<Grid item>
<Button
variant="contained"
type="submit"
classes={{
contained: "btn btn-md btn-primary",
}}>
Submit
</Button>
</Grid>
</Grid>
)
}
cg-bootstrap-standard.css
.btn-primary {
color: #fff;
background-color: black;
border-color: black; }
.btn-primary:hover {
color: #fff;
background-color: black;
border-color: black; }
.btn-primary:focus, .btn-primary.focus {
color: #fff;
background-color: black;
border-color: black;
-webkit-box-shadow: 0 0 0 0.125rem rgba(38, 38, 38, 0.5);
box-shadow: 0 0 0 0.125rem rgba(38, 38, 38, 0.5); }
.btn-primary.disabled, .btn-primary:disabled {
color: #fff;
background-color: black;
border-color: black; }
.btn-primary:not(:disabled):not(.disabled):active, .btn-primary:not(:disabled):not(.disabled).active,
.show > .btn-primary.dropdown-toggle {
color: #fff;
background-color: black;
border-color: black; }
.btn-primary:not(:disabled):not(.disabled):active:focus, .btn-primary:not(:disabled):not(.disabled).active:focus,
.show > .btn-primary.dropdown-toggle:focus {
-webkit-box-shadow: 0 0 0 0.125rem rgba(38, 38, 38, 0.5);
box-shadow: 0 0 0 0.125rem rgba(38, 38, 38, 0.5); }
当我查看 chrome 控制台时,我得到:
样式btn btn-primary
被覆盖,我想将它们的样式应用为应用于按钮的最终样式,而不是 material-ui 的默认样式。我该如何解决?
白衣非少年
相关分类