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-bg-breakpoint

v1.0.3

Published

A customizable Tailwind CSS plugin that responsively changes the background color based on screen size.

Downloads

15

Readme

Tailwind CSS Background Colors By Breakpoint 🖌️

tailwind-bg-breakpoint

🌟 Introduction

This plugin allows you to dynamically change the background color of your elements based on Tailwind's screen breakpoints. This solves the need for a more responsive and visually differentiated design across various screen sizes. This is also useful for debugging and designing responsive layouts.

🛠 Installation

To install the plugin, you can simply run the following command:

npm install tailwindcss-bg-breakpoint
# OR
yarn add tailwindcss-bg-breakpoint

🚀 Basic Usage

After installing the plugin, include it in your tailwind.config.js:

// tailwind.config.js
module.exports = {
  //...
  plugins: [require('tailwindcss-bg-breakpoint')],
};

Use bg-breakpoint in your class name to automatically set the background color based on screen size. If you don't do any customization, the plugin will use the default colors specified below for each breakpoint.

<div className='bg-breakpoint'>responsive background</div>

🎨 Customization

This plugin is designed for flexibility and can be customized according to your needs. You can specify background colors using Tailwind's predefined color classes (e.g., red-500) or custom HEX codes (e.g., #f56565).

Default Colors

Here are the default colors applied for each breakpoint (note: DEFAULT is for anything less than sm. You should not see it for the most part):

  • DEFAULT black
  • sm: lime-400
  • md: amber-500
  • lg: orange-600
  • xl: red-800
  • 2xl: rose-900

Setting Up Customization in tailwind.config.js

To customize the background colors for different breakpoints, you need to define them under the theme key in your tailwind.config.js.

Tailwind Color Classes

To set background colors using Tailwind color classes:

// tailwind.config.js
module.exports = {
  theme: {
    backgroundColorsByBreakpoint: {
      sm: 'green-400',
      md: 'yellow-400',
    },
  },
};

Custom Hex Colors

To set background colors using custom HEX codes:

// tailwind.config.js
module.exports = {
  theme: {
    backgroundColorsByBreakpoint: {
      sm: '#00FF00',
      md: '#FFFF00',
    },
  },
};

Mixed Customization

You can mix Tailwind classes and HEX codes:

// tailwind.config.js
module.exports = {
  theme: {
    backgroundColorsByBreakpoint: {
      sm: 'green-400',
      md: '#FFFF00',
    },
  },
};

Partial Customization

If you only want to specify colors for certain breakpoints, and use default for the rest:

// tailwind.config.js
module.exports = {
  theme: {
    backgroundColorsByBreakpoint: {
      DEFAULT: 'neutral-900'
      md: 'yellow-400',
      lg: 'bg-transparent',
    },
  },
}

Fallback and Error Handling

If an invalid color is provided, the plugin will simply fall back to the default color for that breakpoint.

📜 License

This project is licensed under the MIT License.