Is it possible to apply CSS Variables to customize the Vuetify theme colors?

Hey there! I'm currently working with Vue 2 using Nuxt. I need some help in making Vuetify apply CSS Variables var(--X) wherever colors are used across my project. My goal is to have the ability to dynamically change the theme colors of my Vue app.

{
  theme: {
    themes: {
      light: {
        primary: 'var(--primaryColor)', // <== Insert your CSS Variables here
        secondary: 'var(--secondaryColor)'
      },
    },
  },
}

After implementing the above, all the colors on my site turn out to be white #FFFFFF.

Answer №1

It seems like you're working on the configuration in nuxt.config.js, right? That file doesn't have any knowledge about window or CSS as of now.

To set up CSS variables, you'll either need to import them from another source or define them directly in that file (which is perfectly fine since it's at the top level). The #fff fallback probably kicks in if a value is undefined or similar.

If you want to customize Vuetify colors, refer to this section on customization:

Vuetify generates CSS classes based on these values, which can be accessed in the DOM. These classes follow the same pattern as other helper classes, such as primary or secondary--text. When providing an entire color object (like colors.purple), the lighten/darken variations are used directly instead of being generated.

These values are also accessible through the $vuetify object under the theme property. This allows for dynamic modification of your theme. Behind the scenes, Vuetify will update your theme classes seamlessly, keeping your application up-to-date.

To update these values, you can do the following:

// Light theme
this.$vuetify.theme.themes.light.primary = '#4caf50'

// Dark theme
this.$vuetify.theme.themes.dark.primary = '#4caf50'

PS: The lighten/darken variations are automatically handled for you, making customization easier.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Identifying a selection field problem post implementation of jquery mobile

I recently started using Phonegap and ventured into web development. I was able to successfully implement the HTML select tag in my project, but when I introduced jQuery Mobile, I encountered an issue where the select tag displayed two boxes - one resembli ...

Using callback functions with server.listen in Typescript and JavaScript

I'm puzzled why the following codes are not functioning in TypeScript. (They used to work perfectly fine in my previous JavaScript code!) http.createServer(app).listen(port, (err) => { # Do something }); However, this code works flawlessly (wi ...

It is not possible to use Date.now within passport.js

When creating a user via Facebook on my Node.js website using passport, I want to assign the register date. In my Mongoose Schema, I can use the following for the local provider: regisDate: { type: Date, default: Date.now }, However, when it co ...

Why does Angular's ng-hide not update properly?

My goal is to manipulate a variable named hideProgressBar using the "ng-hide" directive within this view by utilizing the $scope in my controller. However, I am encountering difficulties. The following line functions correctly: $scope.hideProgessBar = tr ...

Arranging elements within distinct div containers

Utilizing Bootstrap 4, I crafted a card-deck containing two cards. Despite the equal height of both cards, the alignment of elements is affected by varying text lengths. <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min ...

Creating custom ExpectedConditions with Protractor for detecting attribute changes

I've been working on creating a custom ExpectedConditions method that can wait for an element attribute to change. Here is the approach I came up with: const CustomExpectedCondition = function() { /** * Check if element's attribute matches ...

Numerous classifications and tags available for c3-angular-directive-c3 charts

I have a project requirement to create a stacked bar chart that should look like the image below: https://i.sstatic.net/MBwXy.png Currently, I am utilizing the c3-angular-directive library along with c3.js for chart creation. The challenge lies in dealin ...

Dropdown selection menu reverts to default styling following ajax response

My form allows users to select their country, which then dynamically changes the dropdown menu to display states or provinces based on the selected country. The issue arises when the dropdown menu loses its CSS styling after an ajax script is called to upd ...

Having difficulty converting the string data to HTML using JavaScript in a Node.js Express application

In my app.js file, I will be sending data to an EJS file. app.get('/', function (req, res){ Blog.find({}, function(err, fountItems){ Blog.insertMany(defaultBlog, function(err){ }) } res.render( ...

Issue with create-react-app and express server not displaying correctly in Internet Explorer

My application functions perfectly with Chrome and Safari. It utilizes React for the front-end and Express for the back-end. However, when I try to open it in Internet Explorer, all I see is a blank white page. Additionally, I encounter this error message: ...

Initiate automatic video play delay on YouTube

Is there a way to delay the automatic start of a YouTube video, for example, by 20 seconds after the page loads? Here is an example without the delay: http://jsfiddle.net/qbqEA/ Thank you! ...

Changing a list of strings into a recursive/nested dictionary or JSON object resembling a file explorer system

Currently, I am working with a Redux Store that is providing me a list of strings representing folders, as shown below: /Documents/Pictures/Test /Documents/Pictures/Test2 /System /Libraries/Node I am looking to convert this into a dictionary or JSON o ...

The integration of Angular and Node API within the IISNode directory structure is experiencing functionality issues

Read more about the question I have successfully set up my Node API and Angular component with IISnode. However, when accessing the application from the IIS server, I noticed that they are showing in different directories (see image below). Additionally, I ...

Submitting data from a JavaScript frontend to a PHP backend

I've exhausted all options in attempting to resolve this issue. The javascript code is designed to send a list of product IDs to a PHP page. When products are selected, the submit button should activate the submit function. function submit() { ...

Looking to transfer the name of the clicked link to a modal in order to execute a PHP/SQL query within the modal window

I am currently utilizing Twitter Bootstrap's modal feature. Within my table, I am mapping MAC addresses to vendor names using the following code: <tbody> <?php foreach ($rowarr as $k => $v) { ?> & ...

The HTML form is causing my JavaScript variable to reset

Hey there! I'm encountering an issue with my form that contains JavaScript functions for adding rows to a table and resetting text fields within the form. The problem arises when I place an incrementing variable called rowCount inside the <form> ...

Tips for concealing JavaScript animations beyond specific boundaries?

So I'm delving into the world of javascript/jquery and an amazing idea popped into my head for a webpage effect. Let me break down the design a bit. My website is neatly contained within a wrapper div, ensuring that the content stays at 1000px and ce ...

tips for transferring API JSON response parameters to material ui table

I'm currently working on creating a table with the material UI. My goal is to populate the rows of the table based on the data received from an API response. The challenge I'm facing is that the API response includes an array of objects with mult ...

There are issues with React Grid2 not adhering to specified row and column definitions and lacking

I am currently in the process of creating a website with react, and I have reached the point where I need to showcase some products. To achieve this, I am utilizing React's Grid2 due to its flexibility for customization and responsiveness to different ...

Several features - Second function malfunctioning

The initial inquiry is effective. However, the subsequent one is encountering issues as it is failing to confirm if an email contains the "@" symbol. My attempted solution involved reordering the functions related to email validation. <body onload="ch ...