Latest in branch 3.1
3.1.8
Released 05 Aug 2022
(3 years ago)
SoftwareTailwind CSS
Branch3.1
Initial release3.1.0
08 Jun 2022
(3 years ago)
Latest release3.1.8
05 Aug 2022
(3 years ago)
Support status19 Oct 2022
(Ended 3 years, 6 months ago)
Release noteshttps://github.com/tailwindlabs/tailwindcss/releases/tag/v3.1.8
Source codehttps://github.com/tailwindlabs/tailwindcss/tree/v3.1.8
Downloadhttps://github.com/tailwindlabs/tailwindcss/releases/tag/v3.1.8
Tailwind CSS 3.1 ReleasesView full list

What Is New in Tailwind CSS 3.1

Category Highlights
New Features First-party TypeScript types, built-in CSS import support in the CLI, opacity syntax for the theme() function, CSS-variable color strings, border-spacing utilities, :enabled and :optional variants, prefers-contrast variants, native dialog backdrop styling, arbitrary variants directly in markup.
Improvements Regex-based class detection for arbitrary variants, tighter integration of postcss-import in the CLI, expanded documentation for CSS variables and new utilities.

How does Tailwind CSS 3.1 improve TypeScript integration?

Tailwind CSS 3.1 ships first-party TypeScript definitions for the entire configuration API.

In practice you add a JSDoc comment above your module.exports in tailwind.config.js:

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [/* ... */],
  theme: { extend: {} },
  plugins: [],
};

This gives you autocomplete, type-checking, and instant feedback in IDEs without extra packages.

What new utilities and variants does Tailwind CSS 3.1 add?

Version 3.1 introduces several utilities and pseudo-class variants that cover common UI patterns.

  • Border-spacing utilities (border-spacing-{size}) for border-collapse: separate tables.
  • enabled: and optional: variants to conditionally apply styles based on form element state.
  • contrast-more: and contrast-less: variants that respond to the prefers-contrast media query.
  • backdrop: modifier for styling the ::backdrop of native <dialog> elements.

Example of a sticky table header using the new border-spacing utilities:

<table class="border-separate border-spacing-0">
  <thead class="bg-gray-50">
    <tr>
      <th class="sticky top-0 border-b border-gray-300">Name</th>
      <th class="sticky top-0 border-b border-gray-300">Email</th>
    </tr>
  </thead>
  ...
</table>

How can I use the theme() function with opacity and CSS variables in Tailwind CSS 3.1?

The theme() function now accepts the slash syntax to adjust alpha channels, and color definitions can be expressed as CSS-variable strings with an <alpha-value> placeholder.

Adjusting opacity directly in CSS:

.card {
  background-color: theme(colors.gray.100 / 60%);
}

Defining a color that respects opacity utilities:

module.exports = {
  theme: {
    colors: {
      primary: "rgb(var(--color-primary) / )",
    },
  },
};

Now bg-primary/50 will render as rgb(var(--color-primary) / 0.5) without extra functions.

How does the new CLI support for CSS imports affect my build workflow?

The Tailwind CLI now bundles postcss-import out of the box, letting you split your stylesheet into logical files without extra configuration.

Typical entry file:

@import "tailwindcss/base";
@import "./components/buttons.css";
@import "tailwindcss/components";
@import "tailwindcss/utilities";

If you run npx tailwindcss -i ./src/main.css -o ./dist/output.css --watch, the imports are resolved automatically, which is especially handy for zero-dependency environments.

How do arbitrary variants work in Tailwind CSS 3.1?

Arbitrary variants let you write any selector logic directly in the class attribute, bypassing the need for a custom plugin.

Example targeting the third child:

<div class="[&:nth-child(3)]:py-0">...</div>

You can also combine feature queries:

<div class="bg-white [@supports(backdrop-filter:blur(0))]:bg-white/50 [@supports(backdrop-filter:blur(0))]:backdrop-blur">...</div>

This provides a powerful escape hatch for edge-case styling while keeping your HTML declarative.

Frequently Asked Questions

Do I need to modify my tsconfig to use the new Tailwind TypeScript types?
No, the JSDoc comment works with any existing tsconfig that already includes JavaScript type checking.

How do I enable CSS imports when using the Tailwind CLI?
Simply add @import statements in your entry CSS file and run the CLI as usual; postcss-import is bundled automatically.

Can I adjust color opacity with the theme() function in my CSS?
Yes, use the slash syntax like theme(colors.gray.100 / 50%) inside any CSS rule.

What is the syntax for defining colors with CSS variables in Tailwind 3.1?
Define the color as a string such as "rgb(var(--color-primary) / )" in the theme.colors section.

Which new pseudo-class variants are available in 3.1?
The release adds enabled:, optional:, contrast-more:, contrast-less:, and backdrop: modifiers.

How do I write an arbitrary variant directly in HTML?
Wrap any selector in square brackets, for example [@supports(backdrop-filter:blur(0))]:backdrop-blur.

Releases In Branch 3.1

VersionRelease date
3.1.805 Aug 2022
(3 years ago)
3.1.729 Jul 2022
(3 years ago)
3.1.611 Jul 2022
(3 years ago)
3.1.507 Jul 2022
(3 years ago)
3.1.421 Jun 2022
(3 years ago)
3.1.314 Jun 2022
(3 years ago)
3.1.210 Jun 2022
(3 years ago)
3.1.109 Jun 2022
(3 years ago)
3.1.008 Jun 2022
(3 years ago)