【发布时间】:2019-04-08 19:43:10
【问题描述】:
我想做的是将多个样式化的组件组合成一个。
使用纯 css 这很容易:
<button class="btn large red"></button>
这是我在 React 中的情感尝试:
import styled from "@emotion/styled/macro";
const A = styled.button({
color: "red"
});
const B = styled.button({
fontSize: 32
});
// I know how to add single styled component. But how to also add B here?
const C = styled(A)({
// some additional styles
});
function App() {
return (
<div className="App">
<A>A</A>
<B>B</B>
<C>C</C>
</div>
);
}
请查看演示:
【问题讨论】:
标签: javascript reactjs