타입 선언
사용 방법
styled, css
import { css } from '@emotion/css'; import { Theme, useTheme } from '@emotion/react'; import styled from '@emotion/styled'; const Header = () => { const theme = useTheme(); return ( <StyledHeader> <h1 className={test(theme)}>헤더</h1> </StyledHeader> ); }; // styled const StyledHeader = styled.header` width: 100%; height: 200px; position: fixed; top: 0; left: 0; background-color: ${({ theme }) => theme.color.blue.main}; `; // css const test = (theme: Theme) => css` color: ${theme.color.red}; `; export default Header;
css is completely react-agnostic, therefore it has no knowledge about react, context, props etc.
It's just a function 😉 You may find this useful though.
Is there no way to use themes with the `css` helper?