We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I'm trying to pass a variable from Styled Components to my tailwind tagged template literal, but can't figure out how to do it. This doesn't work:
const Button = styled.button` ${p => tw`bg-${p.color}`} `
The text was updated successfully, but these errors were encountered:
Having the same issue with something like:
const StyledCard = tw.div` w-full flex-grow lg:w-1/2 bg-pink-300 ${props => (props.noPadding ? `p-0` : `p-8`)} `
Sorry, something went wrong.
I believe you need to use the css helper to do interpolations: https://www.styled-components.com/docs/api#css
So something like this ...
const StyledLink = styled.a` ${tw`no-underline text-black-two`} ${({ navigation }) => navigation && css` &:hover, &:focus { ${tw`text-white-three`} transition: color 0.3s ease; } `} `
Using typescript this doesnt seem to work:
const Button = tw.button<ButtonProps>` bg-${props => props.bg || "primary"} hover:bg-${props => props.bg || "primary"}-dark text-${props => props.color || "white"} border-none font-bold font-mono py-2 px-4 rounded `;
No branches or pull requests
I'm trying to pass a variable from Styled Components to my tailwind tagged template literal, but can't figure out how to do it. This doesn't work:
The text was updated successfully, but these errors were encountered: