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).

Reply

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/

Reply

Thanks

Reply
Join the discussion
Create an account Log in

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

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

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

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

    © 2023 GoRails, LLC. All rights reserved.