全局样式
Emotion中的全局样式是通过<Global>组件来设置的,<Global>组件使用styles属性来接收要设定的样式,可以将css生成的样式直接赋予styles,或者将对象样式赋予styles。<Global>在使用的时候,可以仿照以下示例。
import { Global, jsx } from '@emotion/react';
function App() {
return (
<div>
<Global
styles={css`
h1 {
font-weight: 700;
}
`}
/>
<Global
styles={{
'.some-class': {
fontWeight: 700
}
}}
/>
<div className="some-class">Some text</div>
</div>
);
}