Rails 7 has brought the Asset Pipeline back into the spotlight, which means that bundling CSS without NPM requires gems. This gem allows you to use Tachyons without having to set up a JS bundler in your Rails 7 app.
Add to your Gemfile
:
gem "tachyonscss-rails"
then bundle install
The most common way to use this is:
-
Ensure you have
sassc-rails
in yourGemfile
-
Ensure your
app/assets/stylesheets/application.scss
file is, in fact, a.scss
file and not.css
. If you haven't put anything in it, you can rename it safely. -
Add to
app/assets/stylesheets/applicationscss
:@import "tachyons";
-
If you want to customize Tachyons, the variables partial is a guide to what you can modify. To do that, create the file
app/assets/stylesheets/tachyons-overrides.scss
(or whatever name you like). For example, you could change the green skin like so:$green: 00ff00;
Then add it before the tachyons
@import
in `app/assets/stylesheets/application.scss:@import "tachyons-overrides"; @import "tachyons";
Basically, this gem makes it so you can @import "tachyons";
and it will build the CSS file from the contents of the
tachyons-sass module that this gem wraps.
The version of this gem matches the version of tachyons it bundles, except that it's possible for this gem to bundle
an unreleased version of Tachyons. In that case, the gem will use a fourth number, for example 4.9.0.1
would
indicate that this is the first release beyond 4.9.0
to include Tachyons code added to its main branch since 4.9.0
was released.