• This repository has been archived on 08/Feb/2022
  • Stars
    star
    103
  • Rank 333,046 (Top 7 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 6 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Tailwind plugin for Gridsome.

๐Ÿšจ If you get errors about PostCSS v8, check out Tailwind's docs for the latest info about the compat version.

gridsome-plugin-tailwindcss

This plugin will add Tailwind to your Gridsome project.

Who This Is For

If you want to set up Tailwind with the least amount of effort in a Gridsome project, this is for you. If you want to lean in to the Way of Tailwindโ€”using tailwind.config.js or keep your CSS inside your Vue files' style blocksโ€”this is the plugin for you. If you want to have a global CSS file and dump a bunch of shit in there, you should look elsewhere.

Install

npm install -D gridsome-plugin-tailwindcss tailwindcss@latest

npm install -D postcss-import postcss-preset-env #(if you want these plugins and you've updated the config)

Usage

I've gone ahead and automatically imported the default tailwind.css file from the Tailwind npm package. It's just add a CSS file that includes:

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

You do not need to import Tailwind into a CSS file.

You may be wondering, "Where do I add global CSS?!" Short answer, you don't. Long answer, read the Tailwind docs on creating plugins and use tailwind.config.js to add base styles and create components/utilities there.

If you need to create tailwind.config.js, run ./node_modules/.bin/tailwind init to create one.

Customize

Set any options you want to set in gridsome.config.js.

module.exports = {
  plugins: [
    {
      use: "gridsome-plugin-tailwindcss",
      /**
      * These are the default options.

      options: {
        tailwindConfig: './tailwind.config.js',
        presetEnvConfig: {},
        shouldImport: false,
        shouldTimeTravel: false
      }
      */
    },
  ],
};

If you don't supply a config file path, Tailwind defaults will be used.

Plugins

The following PostCSS plugins can be enabled if you install their dependencies.

postcss-import

Install postcss-import and pass shouldImport: true to enable.

postcss-preset-env

Install postcss-preset-env and pass shouldTimeTravel: true to enable. You may also pass a config object to the plugin as presetEnvConfig.

With this one plugin, you should be ready to use Tailwind right away. Keep your customization to tailwind.config.js whenever possible, but you can use the full power of Tailwind in your Vue components when necessary.

Examples

Happy coding!

Buy Me A Coffee

More Repositories

1

OmniFocus

Scripts for OmniFocus
AppleScript
328
star
2

tailwindcss-plugin-fancy

All the Tailwind plugins that should be in the core package.
TypeScript
43
star
3

gridsome-plugin-tailwindcss-ffs

Sample Gridsome app with TailwindCSS.
Vue
14
star
4

remix-pages-context

A module to make using Cloudflare Pages environment variables and KV-backed sessions easier with Remix.
TypeScript
14
star
5

gridsome-plugin-svg

Super simple SVG component support for Gridsome
JavaScript
9
star
6

gridsome-plugin-ogp

Quickly and easily add common OGP tags for Google, Facebook, and Twitter.
JavaScript
8
star
7

tailwindcss-plugin-delight

Delightful components for your Tailwind project.
JavaScript
7
star
8

gridsome-plugin-purgecss

A Tailwind-friendly Purgecss plugin for Gridsome.
JavaScript
7
star
9

tailwindy

Tailwindy - the Eleventy + Tailwind CSS starter
HTML
5
star
10

qwik-markdown

Helper CLIs for dealing with Markdown routes in Qwik City apps.
TypeScript
4
star
11

businesscard

JavaScript
3
star
12

ldgr

A CLI for working with Ledger files
Ruby
3
star
13

remix-fathom

React Hook to use Fathom in Remix.
TypeScript
3
star
14

simple-setup

My usual repo setup for TypeScript/JavaScript.
TypeScript
2
star
15

purify-invariant

An invariant utility for use alongside purify-ts.
TypeScript
2
star
16

gridtastic

A suite of helpers to augment the Gridsome CLI.
TypeScript
2
star
17

gridsome-plugin-typed

Use TypeScript and TSX in your Gridsome project.
JavaScript
2
star
18

brandonpittman

Brandon Pittman as a Service
JavaScript
2
star
19

stocker

Keep an inventory of things.
Ruby
2
star
20

gridsome-plugin-fathom

Quickly set up Fathom Analytics in your Gridsome project.
JavaScript
2
star
21

formkeep

A library for interacting with the Formkeep API.
Ruby
2
star
22

qwik-bytes

Qwik Bytes examples
TypeScript
1
star
23

gridsome-starter-slides

Gridsome starter for slideshow presentation
Vue
1
star
24

nikki

Record something new learned every day of the year.
Ruby
1
star
25

use-dismiss

The useDismiss() hook for React takes a callback, returns a ref, and invokes the callback when a click event occurs outside the ref's bounds, when the escape key is pressed, or both.
JavaScript
1
star
26

threejs-journey

1
star
27

hooks

Handy hooks I may or may not need in any React project.
TypeScript
1
star
28

use-idb-keyval

React hook to help you use IndexedDB.
TypeScript
1
star
29

site

Brandon's homepage.
TypeScript
1
star
30

tailwindcss-plugin-zeit

CSS
1
star