Creating unique custom styles with Vuetify.js

Is there a way to customize Vuetify component styles without using variables? Currently, the v-btn component has its own styles and using scoped styling doesn't work. I find it cumbersome to have to use !important for each individual CSS property. Are there any alternative methods for applying custom styles to Vuetify components?

new Vue({ el: '#app' })
.block{
  background: rgb(3, 237, 245) ;
  margin: 10px;
  height: 60px; 
  box-shadow: 10px 10px 10px rgba(0, 0, 0, 0.267);
  border-radius: 15px;
  font-family: 'Cookie' ;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.5s ease-in-out;
  width: 200px;
  
}
.wrapper{
  background-color: rgb(0, 126, 131);
}
.block:hover{
  box-shadow: 5px 10px 10px 5px rgba(0, 0, 0, 0.267);
  transform: none;
}
.block:active{
  box-shadow: inset 2px 2px 10px 5px rgba(0, 0, 0, 0.267);
  transform: none;

}
<html>
<head>
  <link href='https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Material+Icons' rel="stylesheet">
  <link href="https://cdn.jsdelivr.net/npm/vuetify/dist/vuetify.min.css" rel="stylesheet">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
</head>
<body>
  <div id="app">
    <v-app>
      <v-content>
        <v-container class="wrapper">
        <div >
          <v-btn class="block " >
            V-Button
          </v-btn>
          <button  class="block  " >
            Button
          </button>
         </div>
          </v-container>
      </v-content>
    </v-app>
  </div>
 
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/vuetify/dist/vuetify.js"></script>
  
</body>
</html>

Answer №1

Encountering an issue with Vue Cli 3, while everything ran smoothly on Vue Cli 2 where the "scoped" feature functioned as intended.

Answer №2

By implementing a more specific selector chain in my CSS, I have successfully overridden the styles of almost all Vuetify components. This involved adding my own class to the component and then targeting that class with the default Vuetify classes.

For instance, let's take the <v-switch> component. In its "off" state (when its v-model is false), it would normally turn gray. However, I wanted to change this color, so I simply added a class and made the adjustment in the CSS.

HTML/template:

<v-switch
    v-model="myModel"
    color="primary"
    class="off-state-orange"
  ></v-switch>

CSS:

.orange-off-state .v-input__control .v-input__slot .v-input--selection-controls__input .v-input--switch__track {
  color: #f2a444;
}

.orange-off-state .v-input__control .v-input__slot .v-input--selection-controls__input .v-input--switch__thumb {
  color: #f2a444;
}

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

Using Vuejs: incorporating imported plugin mixins locally

Can a mixin from a VueJS plugin be used in just one component? I made a plugin and noticed that once I import it, I can use the mixin's functions in all my components. Is there a method to restrict it to just one component, or do plugins inherently ...

Using Javascript to parse SOAP responses

Currently, I am working on a Meteor application that requires data consumption from both REST and SOAP APIs. The SOAP service is accessed using the soap package, which functions properly. However, I am facing challenges with the format of the returned data ...

Identify repeated entries in an HTML table by comparing the values in the first two columns

One of my requirements is to check for duplicate data in an HTML table. The table consists of two columns - product name and batch. While the product name can be repeated, if the same batch repeats for the same product name, I need to display an alert with ...

JSON parsing error within the HTML Sidebar list

I have a JSON file that contains data I need to parse in order to display information in my sidebar. When a user clicks the button labeled "List all sessions", the goal is to showcase all of the available session details grouped by Session ID and location. ...

Create a user interface design for displaying alerts on a web

Currently, I am in the process of creating a form that includes a text box. One important validation I need to implement is that the name entered must be unique. My approach involves accessing the parent div and modifying the entire HTML content within it ...

How come the `setAllSelected` function does not activate the `listbox.valueChange` events, and what can be done to make it happen?

How come setAllSelected is not triggering the emission of listbox.valueChange? What steps can be taken to ensure that it does emit? import { Component, ViewChild } from '@angular/core'; import { CdkListbox, CdkOption } from '@angular/cdk/lis ...

There seems to be an issue with vue not properly refreshing the data on the esri

I have created a composable function called useEsriMap with the following code: export const useEsriMap = () => { const mapObject = ref() const esriObject = computed(() => mapObject.value.esriObject) const panTo = (lat, long) => { esriO ...

Trapped by commitments

I am currently working with an array of projects and an array of dates. My goal is to map the dates to the projects and make API calls to retrieve report URLs. I am trying to collect an array of objects that contain the URLs and the corresponding name-date ...

What is the method for retrieving embedded JavaScript content?

In an attempt to scrape a website using Cheerio, I am facing the challenge of accessing dynamic content that is not present in the HTML but within a JS object (even after trying options like window and document). Here's my code snippet: let axios = ...

The variable remains unchanged after the API call, despite using useState

Despite my efforts to find a solution, I still find myself puzzled by this question that has seemingly been answered before. The issue lies in the synchronization of my code when making a request to the what3words API. The data retrieved is assigned to a ...

Error: Unable to retrieve the value as the property is null

I'm a beginner in jQuery and I'm attempting to create a login form that displays a message when the user enters a short username. However, despite my efforts, the button does not trigger any action when clicked. Upon checking the console, it indi ...

I am curious to know how I can utilize Node.js to sum up values from a specific column within a CSV file

I recently started working with node.js and I'm currently working on a side project that I'm having some trouble with. My goal is to extract values from a specific column in an unzipped csv file and then add them up using node.js. Below is my co ...

Error occurred when attempting to fetch data from a nested JSON object in React/Next.JS

Having trouble retrieving data from my API and encountering this error message. I suspect it may be related to the JSON structure. Interestingly, when using a different URL with nested arrays, it works fine. However, my current data is not cooperating. Any ...

Array filtering functions similarly to marketplace filtering tools

In order to make the filter function like a marketplace filter, I want to only see items related to the selected brand and status. For example: partners = [ 0:{ year: "2022" badge_status: "badge-success" sale_date: "01/07/2022&quo ...

Tracking input fields in Vue.js

I want to determine if the input field is empty or not. Approach If form.name contains a value, execute the increase function If form.name is empty, execute the decrease function Avoid using the increase and decrease functions for each character entered o ...

What's preventing me from changing module.exports? Why is my browser suddenly giving me errors after `npm run build` ran smoothly?

How come the browser is preventing me from executing the following code: Getters.js let Getters = {} Getters.foo = function(){ return 1; } Getters.bar = function(){ return 2; } module.exports = Getters; However, after running npm run build and serve -s ...

Encountering a 404 error while using Node.js for app.get requests with Postgres as the

Currently, I am in the process of learning Node.js by following a tutorial that guides me on building a simple API. The tutorial utilizes a sample database for demonstration purposes, but I decided to use my own Postgres DB instead. However, when trying to ...

AngularFire: Retrieve the $value

Having an issue logging the service.title to the console as it keeps returning as a strange object. .factory('service', function($firebase, FBURL, $routeParams) { var ref = new Firebase(FBURL + "services/" + $routeParams.serviceId); var titl ...

Using Leaflet to beautify categorical json information

As a beginner in coding, I must apologize if a similar question has already been asked. I've spent days searching but haven't found the right combination of terms to find examples for my scenario. I am exploring various small use cases of differ ...