All threads / Tailwind - own components - yes or no?
Ask A Question


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.

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.

excellent explained - thanks a lot.

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

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

Join the discussion

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

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

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

    logo Created with Sketch.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2023 GoRails, LLC. All rights reserved.