# Tailwind css / scaffold

**URL:** <https://discuss.rubyonrails.org/t/tailwind-css-scaffold/80237>\
**Category:** rubyonrails-talk\
**Created:** [March 11, 2022, 4:20pm UTC](https://discuss.rubyonrails.org/t/tailwind-css-scaffold/80237 "2022-03-11T16:20:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![merlin2049er](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/merlin2049er/32/952_2.png) [@merlin2049er](https://discuss.rubyonrails.org/u/merlin2049er)\
**Post date:** [March 11, 2022, 4:20pm UTC](https://discuss.rubyonrails.org/t/tailwind-css-scaffold/80237/1 "2022-03-11T16:20:07Z")

</div>

Hi, I believe I installed tailwind.css into my rails app. When I use a form from an example on the tailwind site, it looks great. Unfortunately, when I run a scaffold, the fields are staggered and need to be fix.

I got 2 questions,

1. is there an option in the scaffold command that specifies tailwind css?
2. or how do I go about editing my form\_for to style it and adding tailwind classes to it.

---

<div class="post-metadata">

**Author:** ![walterdavis](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/walterdavis/32/705_2.png) [@walterdavis](https://discuss.rubyonrails.org/u/walterdavis)\
**Post date:** [March 11, 2022, 6:42pm UTC](https://discuss.rubyonrails.org/t/tailwind-css-scaffold/80237/2 "2022-03-11T18:42:17Z")

</div>

Have a look here, for a start: [ActionView::Helpers::FormBuilder](https://api.rubyonrails.org/classes/ActionView/Helpers/FormBuilder.html) The class documentation includes an example of how you could expand the default method to customize it for your needs.

Also, have a look at simple\_form and some of its peers. Some of those allow you to create your own templates by adding a file in /lib/templates or similar.

I don’t use Tailwind, but I do use Bootstrap and the wonderful bootstrap\_form gem. That wraps the normal Rails tag helpers so they automagically create the whole set of “furniture” needed to make a proper responsive form with Bootstrap styles.

```nohighlight
<%= form.text_field :wakka %>

```

becomes:

```nohighlight
<div class="form-group">
  <label for="wibble_wakka">Wakka</label>
  <input type="text" class="form-control" id="wibble_wakka" name="wibble[wakka]">
</div>

```

I love it, especially for the fact that I don’t have to remember all the arcana of the field nesting unless I’m doing something complex with the layout. And I never have to write out a separate label tag when I add an input of any kind.

Walter

---

<div class="post-metadata">

**Author:** ![walterdavis](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/walterdavis/32/705_2.png) [@walterdavis](https://discuss.rubyonrails.org/u/walterdavis)\
**Post date:** [March 11, 2022, 7:33pm UTC](https://discuss.rubyonrails.org/t/tailwind-css-scaffold/80237/3 "2022-03-11T19:33:47Z")

</div>

This section of the Guide shows a few other examples that might be useful for you.

> **[Action View Form Helpers — Ruby on Rails Guides](https://guides.rubyonrails.org/form_helpers.html#customizing-form-builders)**
>
> Action View Form HelpersForms in web applications are an essential interface for user input. However, form markup can quickly become tedious to write and maintain because of the need to handle form control naming and its numerous attributes. Rails...

You could add a tailwind\_form\_with method, and then some subclassed field helpers that fiddle with the fields, set their tailwind classes, and then call super.

Walter

---

<div class="post-metadata">

**Author:** ![walterdavis](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/walterdavis/32/705_2.png) [@walterdavis](https://discuss.rubyonrails.org/u/walterdavis)\
**Post date:** [March 11, 2022, 7:36pm UTC](https://discuss.rubyonrails.org/t/tailwind-css-scaffold/80237/4 "2022-03-11T19:36:17Z")

</div>

And even more specifically what you wanted to do: [How to Create Custom Scaffold Templates in Ruby on Rails | Web-Crunch](https://web-crunch.com/posts/how-to-create-custom-scaffold-templates-in-ruby-on-rails)

Walter

---

<div class="post-metadata">

**Author:** ![viktorianer](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/viktorianer/32/4275_2.png) [@viktorianer](https://discuss.rubyonrails.org/u/viktorianer)\
**Post date:** [April 17, 2022, 3:57pm UTC](https://discuss.rubyonrails.org/t/tailwind-css-scaffold/80237/5 "2022-04-17T15:57:33Z")

</div>

> [@walterdavis](#):
>
> And even more specifically what you wanted to do: [How to Create Custom Scaffold Templates in Ruby on Rails | Web-Crunch](https://web-crunch.com/posts/how-to-create-custom-scaffold-templates-in-ruby-on-rails)

It is outdated. But with a quick look in Rails source, you can find the difference and adopt. See new partials: [https://github.com/rails/rails/tree/main/railties/lib/rails/generators/erb/scaffold/templates](https://github.com/rails/rails/tree/main/railties/lib/rails/generators/erb/scaffold/templates)
