New Discussion

Notifications

You’re not receiving notifications from this thread.

How to use CSS Variables with Ruby on Rails Discussion

2
General

I asked a question on discord and thought it might be good for it to be here for future reference.
https://discord.com/channels/874684608686477352/874684609164640358/958015390347329658

Question:
I was wondering of a way to dynamically change which class you are calling. ie:
'<%= "text-#{color} bg-#{color}" %>' << this code is not recommended since tailwind needs the full class name to build.

Answer(chris):
you can supply a custom color to Tailwind in the config
module.exports = {
colors: {
'primary': 'var(--primary-color)',
same thing as a regular color there

Thank you for visiting here.

Very informative, thank you Chris and Willard!

Join the discussion
Create an account Log in

Learning Ruby on Rails? Join our newsletter.

We won't send you spam. Unsubscribe at any time.