Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

198
Views
dark mode in laravel while using sass

I'm using sass preprocessor on my laravel project.

on all of my stylesheets, i've used css variables for all colors. all of the variables are stored in 'resource/sass/_variables.scss' and imported in the begining of all stylesheet files.

the inside of '_variables.scss' file is something like this:

$primary-background:#1b203d;
$primary-box-color:#2a2b4a;
$primary-border-color: #7277c422;
$secoundary-box-color: #393a66;
$primary-box-shadow: #1a1b2f;
......

and also in my stylesheet i've used variables like this:

@import 'variables';
#sidebar{
    background-color: $secoundary-box-color;
    border:1px solid $primary-border-color;
    // .....
}

now i'm trying to implement dark mode switch using css variables.

I have no idea how to change css variables, consider it that all my stylesheets (with variables) will be compiled and i have no longer access to css variable on the frontend!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

you can use css custom properties to assign colors

//_variables.scss
$lightTheme: #fff;
$darkTheme: #000;

//style.css
@import 'variables';
:root {
    --theme: #{$lightTheme};
}

body {
    background-color: var(--theme);
}

body.dark {
    --theme: #{$darkTheme};
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!