npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue3-tailwind-components

v0.3.5

Published

A library of Vue 3 components that use Tailwind

Downloads

43

Readme

vue3-tailwind-components

This is a simple set of Vue 3, Tailwind based components. At the moment these consist of:

Demo

I have done a simple demo page here which should give you some idea as to how they look and behave. Please feel free to email me with suggestions or make a pull request. [email protected]

Installation

npm i vue3-tailwind-components --save

Edit tailwind.config.js to look like this. Be especially careful to include this line "./node_modules/vue3-tailwind-components/dist/vue3-tailwind-components.es.js" it tells Tailwind to that we want to use classes that are computed in the components.

Here is a boilerplate tailwind config:

const colors = require('tailwindcss/colors')
module.exports = {
  darkMode: 'class',
  content: [
    "./index.html",
    "./src/**/*.{js,ts,jsx,vue}",
  ],
  safelist: [
    {
      pattern: /bg-(primary|secondary|warning|success|danger|info)-(\d00)/,
      variants:  ['hover', 'focus', 'file','dark', 'dark:hover'],
    },
    {
      pattern: /border-(primary|secondary|warning|success|danger|info)-(\d00)/,
      variants:  ['dark', 'dark:hover'],
    },
    {
      pattern: /divide-(primary|secondary|warning|success|danger|info)-(\d00)/,
      variants:  ['dark', 'dark:hover'],
    },
    {
      pattern: /text-(\w+)-(\d00)/,
      variants:['file','dark']
    },
    {
      pattern: /accent-(\w+)-(\d00)/,
      variants:['file','dark']
    },
    {
      pattern: /placeholder-(\w+)-(\d00)/,
    },

  ],
  theme: {
    extend: {
      colors:{
        primary:colors.slate,
        secondary:colors.lime,
        warning:colors.amber,
        success:colors.green,
        danger:colors.red,
        info:colors.indigo
      }
    },
  },
  plugins: [require("tailwindcss-animate")],
}

You can then just import the ones you want to use like this:



<tw-button>My Button</tw-button>
<script setup>
  import {TwButton} from "vue3-tailwind-components"
</script>

Colors

I expect that if you use this library you will already understand how to use Tailwind generally. It comes with a generous color pallet of gradated colors. In the background Tailwind strips out the classes it does not see directly in your code to keep your css small but this creates a problem for us. It cannot see computed (concatenated strings). In order to use our components you will need to edit your. tailwind.config.js file in the root of your project.

If you want to use every color that Tailwind supply in their default theme you could use this safe list:

 ...
safelist: [
  {
    pattern: /bg-(primary|secondary|warning|success|danger|info)-(\d00)/,
    variants:  ['hover', 'focus', 'file','dark', 'dark:hover'],
  },
  {
    pattern: /border-(primary|secondary|warning|success|danger|info)-(\d00)/,
    variants:  ['dark', 'dark:hover'],
  },
  {
    pattern: /divide-(primary|secondary|warning|success|danger|info)-(\d00)/,
    variants:  ['dark', 'dark:hover'],
  },
  {
    pattern: /text-(\w+)-(\d00)/,
    variants:['file','dark']
  },
  {
    pattern: /accent-(\w+)-(\d00)/,
    variants:['file','dark']
  },
  {
    pattern: /placeholder-(\w+)-(\d00)/,
  },

],

This tells Tailwind - Do not remove any color classes for background, border or text (that is over 2000!) from the CSS.

A more optimal solution is to use color aliases. Those who have used Bootstrap css will be familiar with color aliasing. The advantage of this approach is that we can control the color of all components from one place.

Dark mode

All the components have dark mode styling. if that is your bag

Color aliases in tailwind.config.js like this:

...
theme: {
    extend: {
        colors:{
            primary:colors.slate,
                secondary
        :
            colors.lime,
                warning
        :
            colors.amber,
                success
        :
            colors.green,
                danger
        :
            colors.red,
                info
        :
            colors.indigo
        }
    }
,
}
...

Running this project locally

See Vite Configuration Reference.

Project Setup

npm install

Compile and Hot-Reload for Development

npm run dev

Compile and Minify for Production

npm run build