'How to add color on drop down text in Ruby on Rails collection_select

= f.collection_select :budget_line_id,
                            @budget_lines, :id, :description,
                            { prompt: true },
                            class: 'form-control input-sm form-control-sm'

I need to change the text color of elements of this drop down list.



Solution 1:[1]

If you can't apply a CSS rule for one of your classes you can add an inline style tag to your collection_select helper:

= f.collection_select :budget_line_id,
                            @budget_lines, :id, :description,
                            { prompt: true },
                            class: "form-control input-sm form-control-sm",
                            style: "select { color: #333333; }"

If you have a stylesheet you should be able to add:

.form-control select option {
  color: #333333;
}

It may require some tweaking either way, depending on the HTML that is being rendered, but one of those should get you close.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 NM Pennypacker