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

@vicgutt/tailwindcss-debug

v0.1.0

Published

A set of debugging helpers for any TailwindCSS project

Downloads

111

Readme

A set of debugging helpers for any TailwindCSS project

This plugin provides you with convenient debugging helpers to use in development. Here's a quick example:

// tailwind.config.js

module.exports = {
    theme: {
        // ...
    },
    plugins: [
        require('@vicgutt/tailwindcss-debug')({
            screens: {
                //
            },
            outlines: {
                //
            },
        }),

        // Or

        require('@vicgutt/tailwindcss-debug').screens({
            //
        }),
        require('@vicgutt/tailwindcss-debug').outlines({
            //
        }),
    ],
};

Installation

Install the plugin via NPM (or yarn):

# Using npm
npm i @vicgutt/tailwindcss-debug

# Using Yarn
yarn add @vicgutt/tailwindcss-debug

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

// tailwind.config.js

module.exports = {
    theme: {
        // ...
    },
    plugins: [
        require('@vicgutt/tailwindcss-debug'),
        // ...
    ],
};

Options

The plugin exposes a few options that may be used to configure the plugin's behaviour.

| Name | Type | Default | Description | | -------- | ---------------------------- | ----------- | ----------- | | screens | object\|boolean\|undefined | undefined | Options for the Screens plugin. If false, disables the plugin. | outlines | object\|boolean\|undefined | undefined | Options for the Outlines plugin. If false, disables the plugin.

Helpers

The wrapper plugin exposes two underlying plugins: screens & outlines. Each of them may be enabled, disabled, or have their behaviour customized by providing the corresponding plugin option (see above). All resulting CSS styles from those plugins will be added to the components layer.

Screens

The Screens plugin is heavily inspired by tailwindcss-debug-screens and all credits goes to @jorenvanhee. I decided to replicate the feature simply to have better defaults that suits me out of the box.

This plugin adds a small box at the bottom left (configurable) corner of your screen showing you the currently active responsive breakpoint. Here's a demo of what it does: http://play.ailwindcss.com/aaaaaaa.

Usage

Require the plugin in your Tailwing config:

module.exports = {
    theme: {
        // ...
        debug: {
            screens: {
                // ...
            },
        },
    },
    plugins: [
        require('@vicgutt/tailwindcss-debug')({
            screens: {
                //
            },
        }),

        // Or (same as above)

        require('@vicgutt/tailwindcss-debug').screens({
            //
        }),
    ],
};

By default it will style the ::before pseudo-class of the body of the page.

Options

| Name | Type | Default | Description | | -------- | ---------------------------------------- | --------------------------------------------- | ----------- | | enabled | boolean | !process?.env?.NODE_ENV?.startsWith('prod') | Determines whether the plugin should be executed or not. | ignore | string[] | ['dark'] | Set screens to be ignored. Ex.: "md". | selector | string | 'body' | A valid CSS selector to which the plugin will style it's ::before pseudo-class. | label | string | '{key} ({value})' | The text that will populate the content: ''; of the pseudo-class. Two placeholders are available: key which will be replaced by the screen name (ex.: sm, md, ...) and value which will be replaced by the screen value (ex.: 640px, 768px, ...). | position | ['bottom' \| 'top', 'left' \| 'right'] | ['bottom', 'left'] | Specifies where the box should be positioned. The first item of the array should be either top or bottom and the second either left or right.

Styles customization

To customize the CSS styles of the box, add a debug.screens object to your Tailwind theme. Ex.:

{
    theme: {
        // ...
        debug: {
            screens: {
                fontSize: '2rem',
                backgroundColor: '#000',
                // ...
            },
        },
    },
};

Please refer to the src/plugins/screens.ts file to see all the default styles.

Outlines

The idea of the Outlines plugin came from studiometa's debug-outline plugin so a big thank you to @studiometa.

This plugin allows you to visualise your HTML structure by adding colored outlines to elements present in the DOM. Here's a demo of what it does: http://play.ailwindcss.com/aaaaaaa.

Usage

Require the plugin in your Tailwing config:

module.exports = {
    theme: {
        // ...
        debug: {
            outlines: {
                // ...
            },
        },
    },
    plugins: [
        require('@vicgutt/tailwindcss-debug')({
            outlines: {
                //
            },
        }),

        // Or (same as above)

        require('@vicgutt/tailwindcss-debug').outlines({
            //
        }),
    ],
};

Then add the debug (configurable) class to any HTML element you'd like to debug.

Options

| Name | Type | Default | Description | | -------- | ---------------------------------------- | --------------------------------------------- | ----------- | | enabled | boolean | !process?.env?.NODE_ENV?.startsWith('prod') | Determines whether the plugin should be executed or not. | selector | string | '.debug' | A valid CSS selector on which the plugin will apply styles to all the descendant children.

Styles customization

To customize the CSS styles of any element, add a debug.outlines object to your Tailwind theme. Ex.:

{
    theme: {
        // ...
        debug: {
            outlines: {
                h1: {
                    outline: `1px solid hsla(23.91, 100%, 50%, 0.5) !important`,
                },
                // ...
            },
        },
    },
};

Outline colors per HTML tag's display type

| Display type | Hue range | | ----------------------------------------- | ------------------------------------------------- | | block | { min: 0, max: 59 } (red - orange) | | inline-block | { min: 180, max: 239 } (cyan - blue) | | inline | { min: 70, max: 120 } (yellow - green) | | tables (table-caption, table-cell, ...) | { min: 270, max: 299 } (purple - magenta) | | others | { min: 320, max: 330 } (magenta'ish - pink'ish) |

Please refer to the src/plugins/outlines.ts file to see how the default styles are generated.

Contributing

If you're interested in contributing to the project, please read our contributing docs before submitting a pull request.

License

The MIT License (MIT). Please see License File for more information.