Skip to content

Instantly share code, notes, and snippets.

@jhahspu
Last active August 16, 2023 11:55
Show Gist options
  • Save jhahspu/eba0defff50f0cc9d89f090dfa9d0ed8 to your computer and use it in GitHub Desktop.
Save jhahspu/eba0defff50f0cc9d89f090dfa9d0ed8 to your computer and use it in GitHub Desktop.
tailwindcss

Setup

yarn add daisyui

// tailwind.config.js
module.exports = {
  //...
  plugins: [require("daisyui")],
}
// tailwind.config.js
module.exports = {
  //...

  // add daisyUI plugin
  plugins: [require("daisyui")],

  // daisyUI config (optional - here are the default values)
  daisyui: {
    themes: false, // true: all themes | false: only light + dark | array: specific themes like this ["light", "dark", "cupcake"]
    darkTheme: "dark", // name of one of the included themes for dark mode
    base: true, // applies background color and foreground color for root element by default
    styled: true, // include daisyUI colors and design decisions for all components
    utils: true, // adds responsive and modifier utility classes
    rtl: false, // rotate style direction from left-to-right to right-to-left. You also need to add dir="rtl" to your html tag and install `tailwindcss-flip` plugin for Tailwind CSS.
    prefix: "", // prefix for daisyUI classnames (components, modifiers and responsive class names. Not colors)
    logs: true, // Shows info about daisyUI version and used config in the console when building your CSS
  },

  //...
}

Setup

yarn add tailwindcss postcss-cli autoprefixer daisyui npm install -D @tailwindcss/typography npx tailwindcss init

// postcss.config.js
module.exports = {
  plugins: [
    require('tailwindcss'),
    require('autoprefixer'),
    // Add more plugins as needed
  ],
};
// tailwind.config.js
module.exports = {
  content: [
    './templates/**/*.html', // Specify the paths to your Golang templates
    './layouts/**/*.html', // Specify the paths to your Golang templates
  ],
  theme: {
    extend: {},
  },
  variants: {},
  plugins: [],
}
/* styles.css */
@import 'tailwindcss/base';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';

@layer components {
  .navbar-active .hamburger div:first-child {
  @apply rotate-45 translate-y-1.5;
  }
  .navbar-active .hamburger div:last-child {
  @apply -rotate-45 -translate-y-1;
  }
  .navbar-active div:first-child div:first-child div:last-child{
      @apply block lg:flex
  }
}

/* custom styles */

:root {
  scrollbar-gutter: stable;
}

Makefile

cssw:
	clear 
	npx tailwindcss -i ./assets/styles/style.css -o ./assets/styles/tw.css --watch

cssb:
	clear 
	npx postcss assets/styles/style.css -o assets/styles/tw.css

.PHONY: cssw cssb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment