The `tailwind.min.css` file takes precedence over `tailwind.css` in my Nuxt

Having trouble configuring Tailwind to use a custom font without it overriding the tailwind.css file and not displaying the changes?

https://i.stack.imgur.com/ExDCL.png

Check out my files below.

// tailwind.config.js
const defaultTheme = require('tailwindcss/defaultTheme')

module.exports = {
  purge: [
    './components/**/*.{vue,js}',

    './layouts/**/*.vue',

    './pages/**/*.vue',

    './plugins/**/*.{js,ts}',

    './nuxt.config.{js,ts}',
  ],
  darkMode: false, // or 'media' or 'class'
  theme: {
    extend: {
      fontFamily: {
        sans: ['Rubik', ...defaultTheme.fontFamily.sans],
      },
    },
  },
  variants: {
    extend: {},
  },
  plugins: [],
}
// nuxt.config.js
module.exports = {
  ...,
  css: ["~assets/css/tailwind.css"],
  ...,
}
/*@/assets/css/tailwind.css*/
@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
  @font-face {
    font-family: 'Rubik';
    src: url(../fonts/Rubik-Light.ttf);
    font-weight: 300;
  }
  @font-face {
    font-family: 'Rubik';
    src: url(../fonts/Rubik-Medium.ttf);
    font-weight: 500;
  }
  @font-face {
    font-family: 'Rubik';
    src: url(../fonts/Rubik-Regular.ttf);
    font-weight: 400;
  }
}

The custom fonts are properly linked in the tailwind.css file.

Answer №1

Encountered a similar issue today - did you happen to create your nuxt app using the "create-nuxt-app" command, with TailwindCSS as the chosen UI framework, and started off working on the starter template?

If so, there is likely a component named tutorial.vue that references tailwind.min.css as an external resource.

<link> href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ea9e8b83869d83848e899999aad8c4dbc4d8">[email protected]</a>/dist/tailwind.min.css" rel="stylesheet">

To resolve this issue, simply remove that reference and everything should function as intended.

Answer №2

For this project, I decided to incorporate a new font-family that I created called Rubik. I utilized this custom font at the top level div of my design:

/*assets/css/tailwind.css*/
@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
  @font-face {
    font-family: 'Rubik';
    src: url(../fonts/Rubik-Light.ttf);
    font-weight: 300;
  }
  @font-face {
    font-family: 'Rubik';
    src: url(../fonts/Rubik-Medium.ttf);
    font-weight: 500;
  }
  @font-face {
    font-family: 'Rubik';
    src: url(../fonts/Rubik-Regular.ttf);
    font-weight: 400;
  }
}
//tailwind.config.js
module.exports = {
  mode: 'jit',
  purge: [
    './components/**/*.{vue,js}',

    './layouts/**/*.vue',

    './pages/**/*.vue',

    './plugins/**/*.{js,ts}',

    './nuxt.config.{js,ts}',
  ],
  theme: {
    extend: {
      fontFamily: {
        rubik: ['Rubik', ...defaultTheme.fontFamily.sans],
      },
    },
  },
}
<!-- pages/index.vue -->
<template>
  <div class="font-rubik">
    <Tutorial />
  </div>
</template>

<script lang="ts">
import Vue from 'vue'

export default Vue.extend({})
</script>

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

What is the reason behind the NgForOf directive in Angular not supporting union types?

Within my component, I have defined a property array as follows: array: number[] | string[] = ['1', '2']; In the template, I am using ngFor to iterate over the elements of this array: <div *ngFor="let element of array"> ...

What strategies do you employ to manage various themes within a Vue application?

Considering utilizing dynamic styles according to the chosen theme seems like a solid approach. However, I'm interested in hearing any alternative suggestions on this matter. My current setup involves using Vuex for managing the state of the selected ...

What is the best way to retrieve both a response JSON and headers using Got?

Currently, I am utilizing Got for sending requests to a Strapi API from Node.js. The code snippet demonstrates how I achieve this: res.setHeader('Content-Type', 'application/json') try { const request = req.query.request const decod ...

Leveraging ForEach to merge two arrays and generate a fresh entity

I am in search of my final result which should be as follows: result = [{x: '12/12', y: 90 }, {x: '12/11', y: 0}, {x: '12/10', y: 92}, {x: '12/9', y: 0}, ... ] Currently, I have two arrays to work with. The first a ...

How can you modify a button in Ionic 2 based on the login status, using a modal to redirect to a different page once authenticated?

I have a button on my main page that is supposed to display 'Log out' when the user is currently logged in, and 'Log in' when there is no active user session. Clicking on the login button opens a modal. After successful login, the user ...

What is another option for object-fit: cover?

Is there a way to resize an image on my webpage while maintaining its aspect ratio based on the screen size? I want the smaller dimension (width or height) to fit exactly within the element, with the larger dimension overflowing. I came across the objec ...

Using npm properties reader to access a key with multiple suite values from a properties file in Protractor

Recently, I had to find a way to store some data outside of the standard conf.js file. To tackle this requirement, I decided to use the properties-reader node module. However, I encountered some issues when trying to access certain key values. Below are e ...

Choose the value of the dynamically changing id with the same name using jQuery

Whenever I choose the id (they all have the same id number which is fetched dynamically), it displays the value of the first id. Here's how I'm trying to implement it, but it doesn't seem to be working: function editdr() { qty = $(thi ...

Enhance Your Navbar in Bootstrap 3 by Creating Vertically Expanding Links Relative to Brand Image Dimensions

To best illustrate my issue, I will begin with a screenshot of the problem and then explain what I aim to achieve. Here is the current state of my navbar: Currently, the text of the links on the right side is positioned at the top. Additionally, this is h ...

Pause jQuery at the conclusion and head back to the beginning

As a beginner in the world of jQuery, I am eager to create a slider for my website. My goal is to design a slideshow that can loop infinitely with simplicity. Should I manually count the number of <li> elements or images, calculate their width, and ...

Scrolling to an id element in Vue.js can be achieved by passing the ID in the URL using the "?" parameter. This

My challenge involves a URL http://localhost:8080/?london that needs to load directly to the element with an id of london in the HTML section <section id="london"> on the page. Using http://localhost:8080/#london is not an option, even though it woul ...

"Bootstrap - creating a dynamic effect with a repeating pattern overlay and vibrant background color in

I'm having trouble adding a repeating background image to my jumbotron that already has a rebecca-purple background color. I've tried multiple approaches, but can't seem to get it right. Here's the code snippet I'm working with: . ...

What is the process for spawning a terminal instance within a NodeJS child process?

I'm in the process of setting up a discord channel to serve as an SSH terminal. This involves using a NodeJS server to establish the connection. A custom command will then be used to spawn a new terminal instance that can function as a shell. However ...

Achieving perfect alignment of two images within a block and maintaining their center position even when resizing

While working within a Wordpress post, my goal is to insert two images side by side with the block of images centered, one aligned left and the other aligned right (which I have achieved). As the page size decreases, I want the images to stack on top of e ...

What is the best way to smoothly reveal images one by one?

My goal is to smoothly slide three images inside a div, one by one. However, I'm facing an issue where the images stack on top of each other and end up stuck in their original positions. Here is the code snippet I've been working with: <div ...

The default export of Nuxt, referred to as 'mod', could not be located

Using Nuxt with Typescript, I have created a custom component as shown below: <template> <div class="field"> <label class="label" v-if="typeof label !== 'undefined'">{{ label }}</label> <div class=" ...

Increase the border at the bottom while hovering with React.js and the Material UI library

Can someone help me achieve a hover effect similar to the one in this question on Stack Overflow: Hover effect : expand bottom border I am attempting to create the same effect in React using makeStyles of Material UI. Here is my current code: const useSty ...

JavaScript: Developing an interactive Word Guessing Game

Here's some sample code: let ccdisplay = document.querySelector('.crrDisplay'); let incdisplay = document.querySelector('.incDisplay'); let guess = document.querySelector('#character'); let textForm = document.q ...

Tips for executing multiple commands in NodeJS using child_process.exec

NOTE: I checked this question but it didn't provide the answer I needed. In my attempt to design a task runner for Atom, I encountered difficulties when trying to execute multi-line shell scripts. The issue arose when executing the following code: co ...

Understanding how to extract inner text and splitting it can be a challenging task for developers when working with Javascript

Exploring the following basic html code: <div id="content"> This is a test </div> I am puzzled as to why this works: $(function(){ text = 'this is a text'; word = text.split(' '); alert(word[1]) }) while this does not: ...