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

@tw-plugins/extend-aria

v0.1.0

Published

A Tailwind CSS plugin that extends support for WAI-ARIA 1.2 attributes, providing utility variants for boolean and enumerated ARIA states to enhance accessibility styling.

Downloads

8

Readme

Tailwind CSS Extend ARIA Plugin

npm version

A Tailwind CSS plugin that extends support for WAI-ARIA 1.2 attributes, providing utility variants for boolean and enumerated ARIA states to enhance accessibility styling.

Installation:

Install the plugin:

npm install --save-dev @tw-plugins/extend-aria

Usage:

Add the plugin to your Tailwind CSS configuration:

// tailwind.config.js

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [],
  theme: {},
  plugins: [require("@tw-plugins/extend-aria")],
};

or with options:

// tailwind.config.ts

import type { Config } from "tailwindcss";
import extendAria from "@tw-plugins/extend-aria";

const tailwindConfig: Config = {
  content: [],
  theme: {},
  plugins: [
    extendAria({
      // ExtendAriaPluginOptions
    }),
  ],
};

export default tailwindConfig;

Configuration Options:

attributes

A list of extendable WAI-ARIA 1.2 attributes to include in the plugin. Only attributes with boolean or enumerated values are used and accepted.

Attributes with custom or free-form values, such as aria-label, are not included. Users can still extend these manually using Tailwind's arbitrary value feature aria-[].

If not provided, the plugin defaults to including all relevant attributes except deprecated ones (if includeDeprecated is false).

Example:

const extendAria = require("@tw-plugins/extend-aria");

const tailwindConfig = {
  plugins: [
    extendAria({
      attributes: ["aria-checked", "aria-current", "aria-invalid"],
    }),
  ],
};

includeDeprecated

A flag indicating whether to include deprecated ARIA attributes.

Default is false and deprecated attributes like aria-grabbed and aria-dropeffect are excluded from the variants. To include these, explicitly set this option to true.

negate

Specifies how boolean ARIA attributes with "false" values should be handled.

| Value | Description | | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | "relevant" (default) | Only include boolean attributes where "false" has significant meaning (e.g., aria-expanded="false"). Variants for these attributes are generated with the aria-not-_ prefix (e.g., aria-not-expanded for aria-expanded="false"). | | "all" | Include all boolean attributes with both "true" and "false" values. Variants for "false" values are generated with the aria-not-_ prefix. | | BoolAriaAttribute[] | An array of specific boolean attributes to include with "false" values. Variants for these attributes are generated with the aria-not-* prefix, e.g. aria-not-current | | false | Do not include any attributes with "false" values. |

Examples

Default configuration:

// tailwind.config.js

module.exports = {
  plugins: [require("@tw-plugins/extend-aria")],
};

This will include all relevant WAI-ARIA 1.2 boolean and enumerated attributes, excluding deprecated ones, and only extend "false" values where meaningful.

Include deprecated attributes:

// tailwind.config.js

const extendAria = require("@tw-plugins/extend-aria");

module.exports = {
  plugins: [extendAria({ includeDeprecated: true })],
};

Include all boolean negations:

// tailwind.config.js

const extendAria = require("@tw-plugins/extend-aria");

module.exports = {
  plugins: [extendAria({ negate: "all" })],
};

Specific boolean attributes with "false" values:

// tailwind.config.js

const extendAria = require("@tw-plugins/extend-aria");

module.exports = {
  plugins: [extendAria({ negate: ["aria-checked", "aria-pressed"] })],
};

Supported Attributes:

This plugin only supports extendable WAI-ARIA 1.2 attributes that have boolean or enumerated values. Attributes with custom values, such as aria-label, are not included. However, you can still use these with Tailwind CSS's arbitrary value feature.

Here is a list of supported attributes:

| Attribute | Values | Possible outputs | | -------------------- | ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | aria-atomic | true, false | aria-atomic:{utility}, aria-not-atomic:{utility} | | aria-autocomplete | both, inline, list, none | aria-autocomplete-both:{utility}, aria-autocomplete-inline:{utility}, aria-autocomplete-list:{utility}, aria-autocomplete-none:{utility} | | aria-busy | true, false | aria-busy:{utility}, aria-not-busy:{utility} | | aria-checked | true, false, mixed | aria-checked:{utility}, aria-not-checked:{utility}, aria-checked-mixed:{utility} | | aria-current | true, false, date, location, page, step, time | aria-current:{utility}, aria-not-current:{utility}, aria-current-date:{utility}, aria-current-location:{utility}, aria-current-page:{utility}, aria-current-step:{utility}, aria-current-time:{utility} | | aria-disabled | true, false | aria-disabled:{utility}, aria-not-disabled:{utility} | | aria-dropeffect | copy, execute, link, move, none, popup | aria-dropeffect-copy:{utility}, aria-dropeffect-execute:{utility}, aria-dropeffect-link:{utility}, aria-dropeffect-move:{utility}, aria-dropeffect-none:{utility}, aria-dropeffect-popup:{utility} | | aria-expanded | true, false | aria-expanded:{utility}, aria-not-expanded:{utility} | | aria-grabbed | true, false | aria-grabbed:{utility}, aria-not-grabbed:{utility} | | aria-haspopup | true, false, dialog, grid, listbox, menu, tree | aria-haspopup:{utility}, aria-not-haspopup:{utility}, aria-haspopup-dialog:{utility}, aria-haspopup-grid:{utility}, aria-haspopup-listbox:{utility}, aria-haspopup-menu:{utility}, aria-haspopup-tree:{utility} | | aria-hidden | true, false | aria-hidden:{utility}, aria-not-hidden:{utility} | | aria-invalid | true, false, grammar, spelling | aria-invalid:{utility}, aria-not-invalid:{utility}, aria-invalid-grammar:{utility}, aria-invalid-spelling:{utility} | | aria-live | off, assertive, polite | aria-live-off:{utility}, aria-live-assertive:{utility}, aria-live-polite:{utility} | | aria-modal | true, false | aria-modal:{utility}, aria-not-modal:{utility} | | aria-multiline | true, false | aria-multiline:{utility}, aria-not-multiline:{utility} | | aria-multiselectable | true, false | aria-multiselectable:{utility}, aria-not-multiselectable:{utility} | | aria-orientation | horizontal, vertical | aria-orientation-horizontal:{utility}, aria-orientation-vertical:{utility} | | aria-pressed | true, false, mixed | aria-pressed:{utility}, aria-not-pressed:{utility}, aria-pressed-mixed:{utility} | | aria-readonly | true, false | aria-readonly:{utility}, aria-not-readonly:{utility} | | aria-relevant | additions, all, removals, text | aria-relevant-additions:{utility}, aria-relevant-all:{utility}, aria-relevant-removals:{utility}, aria-relevant-text:{utility} | | aria-required | true, false | aria-required:{utility}, aria-not-required:{utility} | | aria-selected | true, false | aria-selected:{utility}, aria-not-selected:{utility} | | aria-sort | ascending, descending, none, other | aria-sort-ascending:{utility}, aria-sort-descending:{utility}, aria-sort-none:{utility}, aria-sort-other:{utility} |

All attributes produces variants for styling based on parent and sibling states, e.g. group-aria-expanded:{utility}, peer-aria-invalid-spelling:{utility}, etc.

Contributing:

Contributions are welcome! If you have suggestions for improving this plugin or find any bugs, please open an issue or submit a pull request.

License:

This project is licensed under the MIT License. See the LICENSE file for more details.