有没有办法将styled-components与react-bootstrap一起使用? react-bootstrap公开了bsClass
属性,而不是className
,这似乎与styled-components不兼容。
有任何经验吗?
有没有办法将styled-components与react-bootstrap一起使用? react-bootstrap公开了bsClass
属性,而不是className
,这似乎与styled-components不兼容。
有任何经验吗?
您可以使用styled-components扩展来自Bootstrap组件的原始样式。您可以在此处找到有关如何使用第三方库(如react bootstrap)与styled-components的更多文档。
const StyledButton = styled(Button)`
color: palevioletred;
font-size: 1em;
margin: 1em;
padding: 0.25em 1em;
border: 2px solid palevioletred;
border-radius: 3px;
`;
这是一个参考用的沙盒:https://codesandbox.io/s/2vpm40qk90
<ThemeProvider />
或在任何组件上使用props.theme
来完成。我们还导出了一个<BootstrapProvider />
组件,其中包括<ThemeProvider />
并提供bootstrap类实用程序,如.d-none
等......在它的范围内。styled(text-center)
font-color: #abc123;` - Casey
styled(Carousel)\
border: 2px solid red; & .carousel-control { background-image: none; } `;` - Dylan Maxey... border: 2px solid palevioletred; ...
;相反,我认为应该像这样写才能被当前编译器识别:const StyledButton = styled(Button)... border-width: 2px; border-color: palevioletred; ...
;这只适用于styled-components。对于常规CSS,它肯定有效。 - Goku