@tailwindcss/container-queries
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

@tailwindcss/container-queries

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

Installation

Install the plugin from npm:

npm install @tailwindcss/container-queries

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

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

Usage

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

<div class="@container">
  <div class="@lg:underline">
    <!-- This text will be underlined when the container is larger than `32rem` -->
  </div>
</div>

By default we provide container sizes from @xs (20rem) to @7xl (80rem).

Named containers

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

<div class="@container/main">
  <!-- ... -->
  <div class="@lg/main:underline">
    <!-- This text will be underlined when the "main" container is larger than `32rem` -->
  </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="@container">
  <div class="@[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 @container-normal class.

Configuration

By default we ship with the following configured values:

Name CSS
@xs @container (min-width: 20rem)
@sm @container (min-width: 24rem)
@md @container (min-width: 28rem)
@lg @container (min-width: 32rem)
@xl @container (min-width: 36rem)
@2xl @container (min-width: 42rem)
@3xl @container (min-width: 48rem)
@4xl @container (min-width: 56rem)
@5xl @container (min-width: 64rem)
@6xl @container (min-width: 72rem)
@7xl @container (min-width: 80rem)

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

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

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.1.1563,552latest
0.0.0-insiders.ef92eba3insiders

Version History

VersionDownloads (Last 7 Days)Published
0.0.0-insiders.ef92eba3
0.0.0-insiders.f8d43071
0.0.0-insiders.000b61b1
0.0.0-insiders.a10d21f1
0.0.0-insiders.c287ac71
0.0.0-insiders.e53d76e0
0.0.0-insiders.c996d7d0
0.1.1563,552
0.0.0-insiders.f8b51dd0
0.0.0-insiders.005fbc30
0.0.0-insiders.7404e480
0.0.0-insiders.3a793f80
0.0.0-insiders.fc441711
0.0.0-insiders.493e1f00
0.0.0-insiders.806591e0
0.1.03,420
0.0.0-insiders.9fd76080
0.0.0-insiders.9fada990
0.0.0-insiders.addaf450
0.0.0-insiders.96fefc60
0.0.0-insiders.287264a0
0.0.0-insiders.392e3a40
0.0.0-insiders.61731190
0.0.0-insiders.d802e0d0
0.0.0-insiders.46e11b81
0.0.0-insiders.b977f680
0.0.0-insiders.37f93491
0.0.0-insiders.62b1d3e0
0.0.0-insiders.ccb15930
0.0.0-insiders.6bc194f1
0.0.0-insiders.a8a8f030
0.0.0-insiders.b5dc4ac0
0.0.0-insiders.fe5aec31
0.0.0-insiders.52a5ef80
0.0.0-insiders.fffc2331
0.0.0-insiders.a49e3e71
0.0.0-insiders.0f3d7d91

Package Sidebar

Install

npm i @tailwindcss/container-queries

Weekly Downloads

125,155

Version

0.1.1

License

MIT

Unpacked Size

8.46 kB

Total Files

5

Last publish

Collaborators

  • reinink
  • adamwathan
  • malfaitrobin
  • thecrypticace