-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
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
Styled API #22
Comments
Should be able to support something like this: In import tw from 'tailwind.macro'
let Header = tw.button`
uppercase
${props => props.size === 'large' ? tw`text-lg` : tw`text-sm`}
` Out import _styled from '@emotion/styled'
let Header = _styled('button')(
{ textTransform: 'uppercase' },
props => props.size === 'large'
? { fontSize: '1.125rem' }
: { fontSize: '.875rem' }
) |
It would be useful to use it to extend so instead of
We could do
|
You can do this already in pretty much the same way you would with standard import tw from 'tailwind.macro'
const Paragraph = tw.p`font-muli mb-8 text-gray-800 font-light`
const ParagraphLarge = tw(Paragraph)`text-lg text-gray-500` |
@bradlc Do you know why when I get this error? Has error
No error
No error
It seems to me it only happens when it's |
@schrapel are you still seeing this on |
Adding classes based on props doesn't work when using To illustrate, this won't work: import { ComponentType } from 'react'
import tw from 'tailwind.macro'
export const Button = tw.button`
rounded
py-2
px-4
m-1
text-white
uppercase
focus:outline-none
${({ color }: ButtonProps) =>
color === 'primary'
? `bg-red-500 hover:bg-red-700`
: `bg-gray-500 hover:bg-gray-700`}
` This will: import { ComponentType } from 'react'
import styled from 'styled-components/macro'
import tw from 'tailwind.macro'
export const Button = styled.button`
${tw`
rounded
py-2
px-4
m-1
text-white
uppercase
focus:outline-none
`}
${({ color }: ButtonProps) =>
color === 'primary'
? tw`bg-red-500 hover:bg-red-700`
: `background-color: gray;`}
` |
@bradlc I do not see this anymore. Sorry I somehow missed this notification. Thanks for the great package. |
Add support for styled-components style API:
Should we use the default export like above, or use a separate named export? For example:
The text was updated successfully, but these errors were encountered: