All threads / How do I style select options?
Ask A Question

Notifications

You’re not receiving notifications from this thread.

How do I style select options?

William Jones asked in General

I have options for a select field from 2 sources (this years options and last years options). In the drop down list I would like to distinguish the options between the sources (e.g. this years options with a green background, last years with a pink background).

I think you have to use a Javascript library to create a custom select box like that. The browser's select box does not allow you to do that.

For example, something like this provides a ton of flexibilty: https://joshuajohnson.co.uk/Choices/ or https://slimselectjs.com/

Join the discussion

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

Join 61,257+ 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

    © 2022 GoRails, LLC. All rights reserved.