惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
D
Docker
Microsoft Security Blog
Microsoft Security Blog
Google DeepMind News
Google DeepMind News
M
MIT News - Artificial intelligence
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
Y
Y Combinator Blog
Vercel News
Vercel News
F
Fortinet All Blogs
B
Blog
Recent Announcements
Recent Announcements
A
About on SuperTechFans
GbyAI
GbyAI
T
The Blog of Author Tim Ferriss
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - Franky
MongoDB | Blog
MongoDB | Blog
Stack Overflow Blog
Stack Overflow Blog
B
Blog RSS Feed
C
Check Point Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
V
Visual Studio Blog
月光博客
月光博客

Tailwind CSS Blog

Tailwind Labs is joining Shopify Tailwind CSS v4.3: Scrollbars, new colors, and more Vanilla JavaScript support for Tailwind Plus Compass: A starter kit for online courses Tailwind CSS v4.1: Text shadows, masks, and tons more Tailwind UI is now Tailwind Plus Tailwind CSS v4.0 Tailwind CSS v4.0 Beta 1 Radiant: A beautiful new marketing site template Headless UI v2.1: Simplified transition API and improved multi-dialog support Automatically clean up whitespace and duplicate class names Catalyst: Application layouts, navigation menus, description lists, and more Headless UI v2.0 for React We're hiring a Design Engineer + Staff Engineer Open-sourcing our progress on Tailwind CSS v4.0 Introducing Catalyst: A modern UI kit for React Tailwind CSS v3.4: Dynamic viewport units, :has() support, balanced headlines, subgrid, and more Heroicons Micro: What are these, icons for ants? Meet Studio: Our beautiful new agency site template Tailwind Connect 2023: Recap of our first in-person event New changelog template + the biggest Tailwind UI update ever Tailwind CSS v3.3: Extended color palette, ESM/TS support, logical properties, and more Protocol: A beautiful starting point for your next API documentation site Tailwind CSS v3.2: Dynamic breakpoints, multi-config, and container queries, oh my! We built you a new personal website + Heroicons v2.0, Headless UI v1.7, and more New Tailwind CSS + Framer Motion template and Tailwind Jobs Tailwind UI: Site templates and all-access Tailwind CSS v3.1: You wanna get nuts? Come on, let's get nuts! Headless UI v1.6, Tailwind UI team management, Tailwind Play improvements, and more Headless UI v1.5: The One With Comboboxes
Tailwind CSS v1.9.0
2020-10-14 · via Tailwind CSS Blog

We just released Tailwind CSS v1.9 which adds support for configuration presets, useful new CSS grid utilities, extended border radius, rotate, and skew scales, helpful accessibility improvements, and more!

Let's dig in to the highlights...

  • Configuration presets
  • Utilities for grid-auto-columns and grid-auto-rows
  • Focus indicator improvements and configurable outlines
  • Extended border radius, rotate, and skew scales
  • Upgrading to v1.9

For the complete summary of changes check out the release notes on GitHub.


Configuration presets

Tailwind CSS v1.9 adds a new presets key to the tailwind.config.js file that makes it possible to configure a custom "base configuration" for your projects.

module.exports = {  presets: [require("@my-company/tailwind-base")],  theme: {    extend: {      // Project specific overrides...    },  },};

Whatever you provide under presets replaces the default Tailwind base configuration, so you can define your own totally custom starting point. This is really helpful if you're part of a team that works on multiple different Tailwind projects that all need to share the same brand colors, font customizations, or spacing scale.

You can even list multiple presets, which are merged together from top to bottom:

module.exports = {  presets: [require("@my-company/tailwind-base"), require("@my-company/tailwind-marketing")],  theme: {    extend: {      // Project specific overrides...    },  },};

The logic to merge your project-specific configuration with your custom base configuration is exactly the same as how things work with the default configuration, so all of the features you're used to like extend still work exactly the way you'd expect.


Utilities for grid-auto-columns and grid-auto-rows

We've added new gridAutoColumns and gridAutoRows core plugins that add new utilities for the grid-auto-columns and grid-auto-rows CSS properties respectively.

These utilities let you control the size of implicitly-created grid columns and rows. Use them to set a default column/row size whenever you don't specify a number of columns/rows for your grid.

<div class="grid auto-cols-max grid-flow-col">  <div>1</div>  <div>2</div>  <div>3</div></div>

Here's a list of the new utilities that are included out of the box:

ClassCSS
auto-cols-autogrid-auto-columns: auto;
auto-cols-mingrid-auto-columns: min-content;
auto-cols-maxgrid-auto-columns: max-content;
auto-cols-frgrid-auto-columns: minmax(0, 1fr);
auto-rows-autogrid-auto-rows: auto;
auto-rows-mingrid-auto-rows: min-content;
auto-rows-maxgrid-auto-rows: max-content;
auto-rows-frgrid-auto-rows: minmax(0, 1fr);

We include responsive variants for these utilities by default, and they can be configured just like you'd expect under the gridAutoColumns and gridAutoRows sections of your tailwind.config.js file.


Focus indicator improvements and configurable outlines

We've updated the outline-none class to render a transparent outline by default instead of rendering no outline. This is really helpful for people who use Windows high contrast mode, where custom box-shadow-based focus styles are completely invisible.

Now you can create custom focus styles using box shadows safely, without making your sites difficult to use for people with low vision.

<button class="focus:shadow-outline focus:outline-none ...">  <!-- ... --></button>

We've also added two new outline styles: outline-white and outline-black.

These utilities render a 2px dotted outline in their respective color, with a 2px offset. They work great as general purpose unobtrusive focus indicators that make it easy for keyboard users to see which element on the screen is selected, without clashing too much with your design.

We've included both white and black variations so you can always be sure to have an option available that has sufficient contrast against whatever background color you're using.

<!-- Use `outline-white` on dark backgrounds --><div class="bg-gray-900">  <button class="focus:outline-white ...">    <!-- ... -->  </button></div><!-- Use `outline-black` on light backgrounds --><div class="bg-white">  <button class="focus:outline-black ...">    <!-- ... -->  </button></div>

Of course, you're also free to create whatever custom focus styles you like using background colors, box shadows, borders, whatever. These are great if you don't want to get too fancy though.

We've made the outline property configurable as well, so you can now define custom outlines in your tailwind.config.js file:

module.exports = {  theme: {    extend: {      outline: {        blue: "2px solid #0000ff",      },    },  },};

You can also provide an outline-offset value for any custom outline utilities using a tuple of the form [outline, outlineOffset]:

module.exports = {  theme: {    extend: {      outline: {        blue: ["2px solid #0000ff", "1px"],      },    },  },};

Extended border radius, rotate, and skew scales

We've added three new border radius utilities by default:

ClassValue
rounded-xl0.75rem (12px)
rounded-2xl1rem (16px)
rounded-3xl1.5rem (24px)

...and an extended set of smaller values for both the rotate and skew utilities:

ClassValue
rotate-11deg
rotate-22deg
rotate-33deg
rotate-66deg
rotate-1212deg
skew-11deg
skew-22deg

Negative versions are included for all of these as well. Super handy for more subtle rotate and skew effects!


Upgrading

Tailwind CSS v1.9 is a non-breaking minor release, so to upgrade all you need to do is run:

# npmnpm install tailwindcss@^1.9# yarnyarn add tailwindcss@^1.9

We have promoted two previously experimental features (defaultLineHeights and standardFontWeights) to future, so we also recommend opting-in to those changes now to simplify the upgrade to Tailwind CSS v2.0 later this fall.

Want to talk about this post? Discuss this on GitHub →