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

tailwindcss-attributes

v1.2.3

Published

Style html elements with TailwindCSS using data and aria attributes

Downloads

100

Readme

TailwindCSS Attributes

A plugin that provides utilities for adding styles with aria attributes. Create to play nice with vanilla-headless

📇 Table of Contents

Installation

NPM

npm (tag) npm NPM npm bundle size GitHub stars

Install the plugin from npm:

Using pnpm

pnpm add -D tailwindcss-attributes

Using npm

npm install tailwindcss-attributes --save-dev

Using yarn

yarn add -D tailwindcss-attributes

Then add the plugin to your tailwind.config.js file:

// tailwind.config.js
module.exports = {
    theme: {},
    corePlugins: {
        aria: false,
    },
    plugins: [require("tailwindcss-attributes")],
}

Usage

Use aria-* and data-* attributes to style html elements


<headless-toggle class="flex items-center group aria-disabled:bg-gray-300" aria-disabled="true">
    <button
            aria-checked="true"
            class="group-data-switch-on:bg-blue-500 bg-gray-200 relative inline-flex flex-shrink-0 h-6 w-11 border-2  border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
            type="button"
    >
        <span class="sr-only">Use setting</span>
        <span
                aria-hidden="true"
                class="group-data-switch-on:translate-x-5 translate-x-0 pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow transform ring-0 transition ease-in-out duration-50"
                data-switch
        ></span>
    </button>
</headless-toggle>

Data Attributes for Vanilla-Headless

Use these vanilla-headless attributes by usingdata-{name}-{value}

....
<button class="data-switch-on:bg-indigo-500">
    <span class="data-switch-off:translate-x-0 data-switch-on:translate-x-5"></span>
</button>
...

| Attribute | Variant | |:-------------------|:-----------------| | data-state="open" | data-state-open | | data-state="close" | data-state-close | | data-switch="on" | data-switch-on | | data-switch="off" | data-switch-off |

Aria Attributes

These aria-* attribute all translate to a value of true

[aria-pressed="true"].aria-pressed\:shadow-sm {
    --tw-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);
    box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
}

Aria attributes variants

The following attribute all evaluate to true

  • aria-atomic:
  • aria-busy:
  • aria-checked:
  • aria-current:
  • aria-disabled:
  • aria-expanded:
  • aria-grabbed:
  • aria-haspopup:
  • aria-hidden:
  • aria-invalid:
  • aria-live:
  • aria-modal:
  • aria-multiline:
  • aria-multiselectable:
  • aria-pressed:
  • aria-readonly:
  • aria-required:
  • aria-selected:

Aria attributes variants with modifiers

Use modifier to access attribute value


<div class="aria-activedescendant-application:text-red-500"></div>
  • aria-activedescendant-{modifier}
    • application
    • combobox
    • composite
    • group
    • textbox
  • aria-autocomplete-{modifier}
    • none
    • both
    • inline
    • list
  • aria-current-{modifier}
    • page
    • step
    • location
    • date
    • time
  • aria-dropeffect-{modifier}
    • copy
    • execute
    • link
    • move
    • none
    • popup
  • aria-haspopup-{modifier}
    • menu
    • listbox
    • tree
    • grid
    • dialog
  • aria-invalid-{modifier}
    • grammar
    • spelling
  • aria-live-{modifier}
    • assertive
    • off
    • polite
  • aria-orientation-{modifier}
    • horizontal
    • undefined
    • vertical
  • aria-pressed-{modifier}
    • mixed
  • aria-relevant-{modifier}
    • additions
    • all
    • removals
    • text
  • aria-sort-{modifier}
    • ascending
    • descending
    • none
    • other

Contributing

Contributions to this plugin are welcome! If you encounter any issues, have feature requests, or want to improve the plugin, feel free to create a pull request or submit an issue on the GitHub repository.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Acknowledgments

  • This plugin is inspired by the needs of web developers using Tailwind CSS.
  • Special thanks to the Tailwind CSS team for creating such an amazing framework.