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-fluid

v0.2.0

Published

Fluid utilities for Tailwind CSS

Downloads

369

Readme

tailwindcss-fluid

Fluid utilities for Tailwind CSS

Install

npm install --save-dev tailwindcss-fluid

Usage

Add the plugin to your Tailwind configuration:

// tailwind.js
module.exports = {
  // ...
  plugins: [
    require('tailwindcss-fluid')({
      // settings
    })
  ]
}

Settings

You define which class names will be generated much like you do in the core Tailwind configuration. The difference is that each variant (e.g. sm, md, lg etc.) has four properties: min, max, minvw, and maxvw:

{
  textSizes: {
    sm: {
      min: '14px',
      max: '20px',
      minvw: '320px',
      maxvw: '1400px'
    }
  }
}

The above settings will generate one new utility class, .text-sm-fluid:

.text-sm-fluid {
  font-size: 14px;
}

@media (min-width: 320px) {
  .text-sm-fluid {
    font-size: calc(14px + 6 * (100vw - 320px) / 1080);
  }
}

@media (min-width: 1400px) {
  .text-sm-fluid {
    font-size: 20px;
  }
}

Supported properties

textSizes, fontWeights, leading, tracking, borderWidths, borderRadius, width, height, minWidth, minHeight, maxWidth, maxHeight, padding, margin, negativeMargin, zIndex, opacity

Setting your values in the core Tailwind config

If you set a property to true it will take the settings from your core config (e.g. module.exports.textSizes):

{
  textSizes: true
}

Note: In this case you will probably want to disable the core textSizes module

Non-fluid values

You can generate non-fluid utilities by defining a single value, like you would normally. This is useful if you want fluid and non-fluid values defined in the same place:

{
  textSizes: {
    sm: '14px',
    md: {
      min: '16px',
      max: '22px',
      minvw: '320px',
      maxvw: '1280px'
    }
  }
}

Suffix

By default all generated class names will end with -fluid. You can override this behaviour with the suffix setting:

{
  suffix: '', // default: '-fluid'
}

Example

Here is an example of using tailwindcss-fluid for all of your (fluid and non-fluid) font-size utilities:

// tailwind.js
module.exports = {
  // ...

  textSizes: {
    sm: '14px',
    md: {
      min: '16px',
      max: '20px',
      minvw: '320px',
      maxvw: '1280px'
    },
    lg: {
      min: '26px',
      max: '40px',
      minvw: '320px',
      maxvw: '1280px'
    }
  },

  // ...

  modules: {
    // ...

    textSizes: false // disable the core module

    // ...
  },

  plugins: [
    require('tailwindcss-fluid')({
      suffix: '',
      textSizes: true // use the settings defined the core config (above)
    })
  ]
}

This configuration will produce three font-size utility classes: text-sm, text-md, and text-lg.

Links