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 37,629+ 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.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.