vue.js - How to Access Quasar CSS Variables Within Script? - Stack Overflow

admin2025-04-15  0

I'm using Quasar 2.17.7.

If I have the below styles in my quasar.variables.scss file:

$company-base: #3c3c3b;
$company-accent: #89c3ce;

$primary: #1976d2;
$secondary: #26a69a;
$accent: #9c27b0;

How can I access these in a script tag? For example...

const accentColor = $q.getColour('company-accent');

I'm using Quasar 2.17.7.

If I have the below styles in my quasar.variables.scss file:

$company-base: #3c3c3b;
$company-accent: #89c3ce;

$primary: #1976d2;
$secondary: #26a69a;
$accent: #9c27b0;

How can I access these in a script tag? For example...

const accentColor = $q.getColour('company-accent');
Share Improve this question edited Feb 4 at 18:04 kissu 47k16 gold badges90 silver badges189 bronze badges asked Feb 4 at 14:09 RejestoRejesto 913 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Given the docs, you can apparently you can access it this way

import { getCssVar } from 'quasar'

const accentColor = getCssVar('company-accent'); // #89c3ce

And write to it this way

import { setCssVar } from 'quasar'

setCssVar('company-accent', '#newColor');
转载请注明原文地址:http://www.anycun.com/QandA/1744714502a86605.html