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 🙏

© 2026 – Pkg Stats / Ryan Hefner

responsive-tailwind

v1.0.0

Published

Type-safe responsive Tailwind class composition with compile-time breakpoint validation.

Readme

responsive-tailwind

Type-safe responsive Tailwind CSS class composition with compile-time breakpoint validation and arbitrary breakpoint support.

responsive-tailwind is a small utility for composing responsive Tailwind CSS classes using an object-based syntax with full TypeScript validation.

It helps organize responsive classes while ensuring every breakpoint value uses the correct Tailwind prefix, preserving Tailwind's static class detection.

Features

  • ✅ Object-based responsive class composition
  • ✅ Compile-time validation of breakpoint prefixes
  • ✅ Supports Tailwind default breakpoints
  • ✅ Supports arbitrary breakpoints (min-[...] / max-[...])
  • ✅ Works with Tailwind JIT/static class detection
  • ✅ Uses tailwind-merge for intelligent class merging
  • ✅ Full TypeScript support

Installation

npm install responsive-tailwind

or:

yarn add responsive-tailwind

or:

pnpm add responsive-tailwind

Usage

import { responsive } from "responsive-tailwind";

const className = responsive({
  base: "flex flex-col gap-4",
  md: "md:flex-row",
  lg: "lg:gap-8",
});

// Result:
// "flex flex-col gap-4 md:flex-row lg:gap-8"

Use the breakpoint key to organize your classes, and include the full Tailwind prefix in the value.


React Example

Use responsive directly inside the className prop:

import { responsive } from "responsive-tailwind";

export function Card() {
  return (
    <div
      className={responsive({
        base: "flex flex-col gap-4 p-4",
        md: "md:flex-row",
        lg: "lg:p-8",
      })}
    >
      <div className="flex-1">
        Content
      </div>

      <div className="flex-1">
        Sidebar
      </div>
    </div>
  );
}

The generated class string will be:

flex flex-col gap-4 p-4 md:flex-row lg:p-8

This allows you to keep responsive styles organized while still using Tailwind classes normally.


Why include the prefix?

responsive-tailwind intentionally does not generate breakpoint prefixes automatically.

Instead of:

responsive({
  md: "flex-row"
});

you write:

responsive({
  md: "md:flex-row"
});

This keeps classes visible to Tailwind's static analyzer and prevents issues with dynamic class generation.


TypeScript validation

Invalid breakpoint prefixes are detected during development.

Valid

responsive({
  sm: "sm:flex-col",
  md: "md:flex-row",
  lg: "lg:grid-cols-3",
});

Invalid

responsive({
  md: "flex-row",
});

TypeScript error:

Class 'flex-row' in md must start with 'md:'

Custom breakpoints

You can use Tailwind arbitrary breakpoints:

responsive({
  base: "grid",
  "min-[900px]": "min-[900px]:grid-cols-3",
  "max-[500px]": "max-[500px]:hidden",
});

Examples:

responsive({
  "min-[768px]": "min-[768px]:flex-row",
  "max-[1024px]": "max-[1024px]:grid-cols-1",
});

Supported breakpoints

Default Tailwind breakpoints:

responsive({
  sm: "sm:...",
  md: "md:...",
  lg: "lg:...",
  xl: "xl:...",
  "2xl": "2xl:...",
});

Arbitrary breakpoints:

responsive({
  "min-[value]": "min-[value]:...",
  "max-[value]": "max-[value]:...",
});

API

responsive(classes)

Receives a responsive class map and returns a merged Tailwind class string.

Example:

responsive({
  base: "flex items-center",
  md: "md:flex-row",
  "min-[1200px]": "min-[1200px]:gap-8",
});

Output:

flex items-center md:flex-row min-[1200px]:gap-8

How it works

The library:

  1. Receives classes grouped by breakpoint.
  2. Validates that each breakpoint value contains its matching Tailwind prefix.
  3. Merges all classes using tailwind-merge.
  4. Returns a single className string.

License

MIT