All threads / Override CSS in Gem with CSS from app
Ask A Question

Notifications

You’re not receiving notifications from this thread.

Override CSS in Gem with CSS from app

Neil Tonge asked in Rails

Hi,

I'm working on a Rails Gem. The gem provides one view and a basic stylesheet for it.

When installed in an app, i'd like to be able to override the basic styles with other styles in the app itself. How can this be done? I'm confused as i'm not sure how to link the new styles to the view when the view is part of the gem. I don't wish to duplicate the view into the app though. Just wish to write an override set of styles and have that apply to that one view template.

I was thinking about somehow specifying a config option where a path to a file can be set, and if this is configured then it will conditionally show in the view. Is this the right approach or is there a better way?

Thanks,
Neil

Join the discussion

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

Join 66,029+ 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.