const someStyle = css`
colors : ${({theme}) => theme.colors.primary;
${(props) => props.active ? css`
background-color: ${({theme}) => theme.colors.backgroundColorActive};
`}
`
const SomeButton = styled.div`
${someStyle}
`
Can I use css
template literals nested in another css template literals?
Even easier you can just use a simple Template strings:
const someStyle = `
color: ${({theme}) => theme.colors.primary;
${(props) => props.active ? `
background-color: ${({theme}) => theme.colors.backgroundColorActive};
`}
`
const SomeButton = styled.div`
${someStyle}
`
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.