Skip to content

A simple demo how to use CSS variables in the tailwind.config to create a light/dark theme toggle on your website!

Notifications You must be signed in to change notification settings

shayaulman/vue-tailwind-theme-switcher-demo

Repository files navigation

vue-cli

Setting up Tailwind with vue-cli is really simple, just install Tailwind:

npm install tailwindcss

Then add it to your PostCSS config (use a separate postcss.config.js file):

module.exports = {
  plugins: [
    require('tailwindcss'),
    require('autoprefixer'),
  ]
}

Next, create a CSS file for your Tailwind styles. We've stored in it src/assets/tailwind.css for this example:

@tailwind base;
@tailwind components;
@tailwind utilities;

Finally, import that CSS file at the bottom of your main App.vue component:

<template>
  <!-- ... --->
</template>

<script>
  /* ... */
</script>

<style src="./assets/tailwind.css">

Project setup

npm install

Compiles and hot-reloads for development

npm run serve

Compiles and minifies for production

npm run build

Lints and fixes files

npm run lint

About

A simple demo how to use CSS variables in the tailwind.config to create a light/dark theme toggle on your website!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published