Search code examples
ruby-on-railsrubystylesformtastic

How do I style the default Formtastic labels?


I'm a new to Formtastic here. How do I go about styling Formtastic elements? By default, the labels beside my form elements are colored white. Is this normal or is it because I don't have a formtastic.css in my stylesheets folder?


Solution

  • I was able to figure it out myself.

    In my zsh shell in the directory for my Rails app, I ran rails generate formtastic:install.

    I also put in the requisite requires in my application.css.scss file:

         *= require formtastic
         *= require my_formtastic_changes
    

    Following this, I just created a my_formtastic_changes.css.scss file in my stylesheets directory and implemented the following bit.

        <%= semantic_form_for @section do |f| %>
          <%= f.inputs do %>
           <div id="section-details">
             <%= f.input :name %>
             <%= f.input :category %>
             <%= f.input :description %>
             <%= f.input :filepath %>
             <%= f.input :site_section_id %>
           </div>
        <% end %>
    

    I just then styled it in the my_formtastic_changes.scss with this:

        #section-details label {
            color: #000;
        }