Skip to content
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

Using arbitrary values #58

Open
vladikopl01 opened this issue Apr 27, 2022 · 3 comments
Open

Using arbitrary values #58

vladikopl01 opened this issue Apr 27, 2022 · 3 comments

Comments

@vladikopl01
Copy link

vladikopl01 commented Apr 27, 2022

Hello, it would be nice to have this in your library, or is it already there?

Example of using arbitrary variants to style elements with a custom selector:

import tw from 'tailwind-styled-components'

const Button = tw.button`
  bg-black
  [> i]:block
  [> span]:(text-blue-500 w-10)
  [div.container]:(grid m-8)
`

const Component = () => (
  <Button>
    <i>Icon</i>
    <span>Label</span>
    <div className="container">Container</div>
  </Button>
)
@vladikopl01
Copy link
Author

vladikopl01 commented Apr 27, 2022

Or even in such structure to implement same logic:

import tw from 'tailwind-styled-components'

const Button = tw.button`
  bg-black

  i {
    block
  }

  span {
    text-blue-500
    w-10
  }

  div.container {
    grid
    m-8
  }
`

const Component = () => (
  <Button>
    <i>Icon</i>
    <span>Label</span>
    <div className="container">Container</div>
  </Button>
)

@fernandame
Copy link

I believe the second syntax makes more sense and I absolutely love it. Would spare a lot of time and it's cleaner.

@MathiasGilson
Copy link
Owner

Have you tried to use @tailwindcss/nesting ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants