Ask A Question

Notifications

You’re not receiving notifications from this thread.

Tailwind - own components - yes or no?

Bruno Steinmann asked in CSS

i have started with tailwindcss yesterday the first time and must say - wow!

but something is confusing me from the beginning. in tutorials/videos etc. everybody talk about: do not write your own css-file, just put the whole styling into view-pages. but why - it is not DRY? for a style that is used one time (e.g. body bg-grey-100) or even a couple of times in layout templates etc. it makes sense to handle style in the views.

all the styles i am using throughout the entire app (such as buttons, links, cards etc.) i will "outsource" to the css-file (@apply).

  • reusable
  • cleaner code in views (better reading)
  • faster changes
  • DRY

i am on the right way with this? or is there another approach behind "no own css components"?

thanks for your thoughts - stay safe.

Reply

Adam talks about this in one of the Tailwind videos. I'll let him explain it cuz he can do a better job than me. https://twitter.com/adamwathan/status/1245883595396386816

Reply

excellent explained - thanks a lot.

Reply

Bruno, have you had a chance to look at ViewComponent? https://github.com/github/view_component Might be useful to pair with tailwind classes (and possibly extract @apply utilities) if you don’t want to start using Vue/React/etc.

Reply

@Ricky thanks for this input. i already have started to use more Vue including components / slots.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,946+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.