Struggling to customize Vuetify styles with my own stylesheet

In my current project, I am utilizing Vue2 and Vuetify. One of the main challenges I am facing is that my Vuetify styles are always imported after my own custom styles.

I attempted the following:

App.vue

<template>
  <v-flex>
    <v-card class="myCard"></v-card>
  </v-flex>
</template>

<style>
  .myCard {
      background-color : yellow;
  }
</style>

main.js

import App from './Components/App.vue';
import 'vuetify/dist/vuetify.css'
import Vuetify from 'vuetify';
import Vue from 'vue';

Vue.use(Vuetify);

It appears that the style is being loaded within the <head/> tag before vuetify styles.

I have tried changing the order of imports as follows:

import 'vuetify/dist/vuetify.css'
import Vuetify from 'vuetify';
import Vue from 'vue';
import App from './Components/App.vue';

Vue.use(Vuetify);

However, this approach has not been successful. I also experimented with importing all styles in a Main.scss file, prioritizing vuetify styles first followed by my own stylesheets, but this method did not work either.

Is there a way to control the order of stylesheet imports?

Answer №1

After some trial and error, I managed to solve the issue by making a simple tweak in my tailwind.config.js file.

module.exports = { important: '#main', }

This modification adds a selector to the tailwind classes, giving them more priority without resorting to using !important in the css rule. This adjustment was sufficient to override the conflicting Vuetify styles in my project.

https://tailwindcss.com/docs/configuration#selector-strategy

Answer №2

Should you import the vuetify.css file directly into your main.css before all other CSS content? Or is it better to create a main.scss file where you can import various CSS files and control the order in which they are loaded, similar to the following:

@import url('https://fonts.googleapis.com/css?family=Lato:300,400,700|Roboto+Mono');

@tailwind preflight;
@import 'buttons';
@import 'tables';
@import 'icons';
@import 'checkbox';
@import 'select';
@import 'tabs';
@import 'cards';
@import 'alerts';
@import 'forms';
@tailwind utilities;

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

Switching up the size of individual components in the Bootstrap grid system: The ultimate guide

Is it possible to adjust the width of specific elements in Bootstrap's grid system without affecting the default customization? Here is an example of what I am referring to: For example, I would like to make col-xs-1 smaller as seen in the top row ( ...

Responses that include a 204 error code followed by a 500 error code

I have a scenario where my application needs to send data to an API developed by our team leader using NodeJS with Express.js. On my side, I have a Laravel application that utilizes VueJS for the UI. Inside the Vue JS component, I am making use of axios t ...

It is not possible to alter the styles of the ng-daterangepicker Angular plugin

After installing the angular2 plugin "ng-daterangepicker", I attempted to resize a div within it by modifying the .sass file. However, despite clearing the cache, the changes did not reflect in my browser. It seems that I may need to make adjustments to .s ...

Steps for closing the menu by clicking on the link

My issue with the menu on the landing page is that it only closes when clicking the cross button. I want it to close when any link from the menu is clicked. I attempted to add code using querySelector, but it only worked for the home link and not the other ...

Issue with random pages where global header.php is not showing a specific image

I'm currently revamping a website that was originally developed using codeigniter. The backend is quite chaotic with no clear identifiers for anything. I recently updated the banner in the header.php file, adjusting the style to suit the requirements. ...

Verifying the presence of div elements using Jasmine, Webpack, and vue.js

Within my Vue component, I have implemented code that dynamically displays a div based on certain conditions: <div v-if="successCriteria()" id="success"> <div class="row"> <div class="col-md-12"> <Commit-chart :data="cha ...

Maximizing the Potential of Bootstrap 5's Grid System

I'm struggling a bit with the Bootstrap grid system. I want to create 6 divs or containers that span the full width on smaller devices like mobiles, use 25% of the width on medium devices like tablets, and display all 6 in a single row on large deskto ...

How to Retrieve the Current div's ID in VueJS

When using the v-for directive to dynamically generate an id for my div, I need to pass this unique id to a specific function. <div v-for="(item, index) in items" :key="index" :id="'form' + index" > ...

What could be causing the flex item to be wider than its container?

One issue that can arise when utilizing flexbox is the scenario where, as demonstrated below, the content exceeds the width of the viewport causing the flexbox items to become wider than their container. What are the factors contributing to this situat ...

Deploying a React application to Heroku or GitHub pages can sometimes alter the appearance of styles and CSS

As a newbie to coding, I've managed to create multiple full-stack apps, but I've encountered a frustrating issue each time I deploy them to Heroku or GitHub Pages. Every element on the page seems to shrink in size compared to what it was on my lo ...

How to apply unique styles to multiple elements with the same class using jQuery?

How can I add different classes to multiple div elements with the same class based on their content? <div class = "flag"> Yes </div> <div class = "flag"> No </div> <div class = "flag"> Yes </div> <div class = "flag"& ...

New to CSS: Applying a background image on top of a gradient without any transparency on the image

Appreciate you taking the time to read this I'm facing an issue where I want to have a background image overlaid on a gradient, but every solution I've tried ends up making the background image transparent, causing a discrepancy in colors. I att ...

What exactly is the mechanism behind how the text-overflow property's fade value operates?

I am struggling to add a one line description to each flex-child using the fade() value, but it seems to not be working as expected. .flex-container { display: flex; flex-wrap: wrap; justify-content: center; flex-direction: row; } .flex-child { ...

Clicking on a date in Vue.js Fullcalendar

My goal is to retrieve a date value from the onDateClick function of fullCalendar using vue.js and then pass this data to a prop that can be stored in my backend via Laravel. However, I am encountering various undefined errors no matter how I approach th ...

Design a universal web service indicator akin to an "activity indicator" that works seamlessly across all web browsers

My web service is quite database-heavy (using PHP and mySQL), resulting in the user being faced with a blank screen for several seconds. When a user clicks a link on an HTML page, a javascript function is triggered, which then initiates an AJAX call to in ...

Saving videos for offline viewing in a Vue Progressive Web App with Vue.js 3

I'm having a bit of an issue with my Vue 3 and Typescript setup. I've created a PWA where I display videos, which works perfectly online. However, when I try to access them offline, the videos don't load properly. I have stored the videos in ...

Should the text underneath the image be placed above the rest of the images?

In the process of developing my game, I encountered a challenge where text needs to be dragged under specific images. To achieve this, I envision creating tabs below the images for the text to be dragged onto. My initial approach involved wrapping each im ...

What value is used as the default for justify content?

MDN states that the default value of justify-content is normal, even though it's not listed in the accepted values. What exactly does a normal value mean? normal This means that items are packed in their default position as if no justify-cont ...

Using jQuery to create animated effects for hidden input fields

The struggle to smoothly animate and fade in a hidden text field can be witnessed in this example. The goal is to seamlessly move all elements around the text field and button while fading in/out the hidden element. However, it appears that towards the en ...

buttons are arranged horizontally, stacked neatly on top of one another

I'm currently working on a setup for toggle buttons using absolute positioning for labels on top of checkboxes. My goal is to have them aligned horizontally, but instead, they are stacking on top of each other. <ul style="display: block; float: le ...