Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tailwind SCSS with variables.scss

I am practising tailwind scss, and trying to create a theme similar to bootstrap. My current code for primary button, below which is working fine.

.btn-{
    &primary{
        @apply bg-blue-500 text-white;
        &:disabled{
            @apply bg-blue-500/50;
        }
    }

and my alert is

.alert-{
    &primary{
        @apply bg-blue-500 text-white;
    }

As bg-blue-500 is taken as primary color, i prefer to variable.scss file like

$bg-primary: @apply bg-blue-500; //throws error at scss

I dont want to hardcode the color, instead use the tailwind values. Is there a way to achieve this

like image 609
Alaksandar Jesus Gene Avatar asked Oct 18 '25 12:10

Alaksandar Jesus Gene


1 Answers

Since this question was posted 10 months ago I gues this not urgent anymore but maybe this helps someone else:

For that purpose you can use the theme function provided by tailwind for that purpose:

$myVar: theme(colors.blue.500)

Resource: https://tailwindcss.com/docs/functions-and-directives (at the very bottom)

like image 106
NHillerbrand Avatar answered Oct 22 '25 05:10

NHillerbrand



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!