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

@krzysztof318/tw-container-queries

v0.3.2

Published

A plugin for Tailwind CSS v3.2+ that provides utilities for container queries.

Downloads

9

Readme

@krzysztof318/tw-container-queries

A plugin for Tailwind CSS v3.2+ that provides utilities for container queries.

This is fork of original repo LINK

I modificated prefix '@' to 'qc-' so now it works better with Razor syntax and many other things.

Installation

Install the plugin from npm:

npm install -D @krzysztof318/tw-container-queries

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

// tailwind.config.js
module.exports = {
  theme: {
    // ...
  },
  plugins: [
    require('@krzysztof318/tw-container-queries'),
    // ...
  ],
}

Usage

Start by marking an element as a container queryable using the qc-queryable class, and then applying styles based on the size of that container using the container variants like qc-md:, qc-lg:, and qc-xl::

<div class="qc-queryable">
  <div class="qc-lg:underline">
    <!-- This text will be underlined when the container is larger than or equals `1024px` -->
  </div>
</div>

Default container-type is inline-size.

By default we provide queryable sizes from qc-sm (640px) to qc-2xl (1536px).

Max modifiers

You can mark an element with qc-max-{breakpoint} class, for example qc-max-md (width < 768px), qc-max-lg (width < 1024px>).

<div class="qc-queryable">
  <div class="qc-max-lg:underline">
    <!-- This text will be underlined when the container is smaller than `1024px` -->
  </div>
</div>

Range modifiers

You can mark an element with qc-{breakpoint}:qc-max-{breakpoint} class, for example qc-sm:qc-max-lg (min-width: 640px and width < 1024px).

<div class="qc-queryable">
  <div class="qc-sm:qc-max-lg:underline">
    <!-- This text will be underlined when the container is larger than or equals `640px and smaller than `1024px` -->
  </div>
</div>

Named containers

You can optionally name containers using a qc-queryable/{name} class, and then include that name in the container variants using classes like qc-lg/{name}:underline:

<div class="qc-queryable/main">
  <!-- ... -->
  <div class="qc-lg/main:underline">
    <!-- This text will be underlined when the "main" container is larger than `1024px` -->
  </div>
</div>

Arbitrary container sizes

In addition to using one of the container sizes provided by default, you can also create one-off sizes using any arbitrary value:

<div class="qc-queryable">
  <div class="qc-[17.5rem]:underline"></div>
    <!-- This text will be underlined when the container is larger than `17.5rem` -->
  </div>
</div>

Removing a container

To stop an element from acting as a container, use the qc-queryable-normal class.

Arbitrary container

You can create container with arbitary value:

<div class="qc-queryable-[size]">
  <!-- ... -->
</div>

This will be compiled to:

.qc-queryable-\[size\] {
  container-type: size;
}

Fixed size container component

I provided also qc-container similar to tailwind container component:

<div class="qc-queryable">
  <div class="qc-container"></div>
    <!-- Fixed size -->
  </div>
</div>

By default I provide container sizes. Containers are not default centered but you can enable this in configuration.

With a prefix

If you have configured Tailwind to use a prefix, make sure to prefix both the qc-queryable class and any classes where you are using a container query modifier:

<div class="tw-qc-queryable">
  <!-- ... -->
  <div class="qc-lg:tw-underline">
    <!-- ... -->
  </div>
</div>

Configuration

By default we ship with the following configured breakpoints:

| Name | CSS | Name | CSS | | -------- | -------------------------------------------- | ------------ | -------------------------------------------- | | qc-sm | @container (min-width: 640px) | qc-max-sm | @container (width < 640px) | | qc-md | @container (min-width: 768px) | qc-max-md | @container (width < 768px) | | qc-lg | @container (min-width: 1024px) | qc-max-lg | @container (width < 1024px) | | qc-xl | @container (min-width: 1280px) | qc-max-xl | @container (width < 1280px) | | qc-2xl | @container (min-width: 1536px) | qc-max-2xl | @container (width < 1536px) |

Default containers:

| Breakpoint | Properties | | ---------- | ------------------- | | none | width: 100% | | 240px | max-width: 240px | | 320px | max-width: 320px | | 480px | max-width: 480px | | 640px | max-width: 640px | | 768px | max-width: 768px | | 1024px | max-width: 1024px | | 1280px | max-width: 1280px |

You can add breakpoints which are available for this plugin under the containers key in your tailwind.config.js file:

It will be applied to qc-{breakpoint} and qc-max-{breakpoint}.

// tailwind.config.js
module.exports = {
  theme: {
    extend: {
      'qc-queryables': {
        '2xs': '16rem',
      },
    },
  },
}

Or override all breakpoints with yours:

// tailwind.config.js
module.exports = {
  theme: {
    'qc-queryables': {
      'xs': '16rem',
      'md': '32rem',
      'lg': '48rem',
    },
  },
}

You can also configure containers fixed sizes and their breakpoints:

// tailwind.config.js
module.exports = {
  theme: {
    'qc-containers': {
      '240px',
      '320px',
      '480px',
    },
  },
}

You can enable auto centering for qc-containers:

// tailwind.config.js
module.exports = {
  theme: {
    container: {
      center: true,
    },
  },
}