Skip to content

Commit 9d6807e

Browse files
committed
WIP
1 parent c652f48 commit 9d6807e

File tree

1 file changed

+142
-77
lines changed

1 file changed

+142
-77
lines changed

src/pages/blog/tailwindcss-v3-3/index.mdx

Lines changed: 142 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ export const meta = {
99
authors: [adamwathan],
1010
}
1111

12+
<!--excerpt-->
13+
14+
Tailwind CSS v3.3 is here bringing a bunch of new features people have been asking for forever, and a bunch of new stuff you didn't even know you wanted.
15+
16+
<!--/excerpt-->
17+
1218
<div className="my-8">
1319
<img src={card.src} alt="Tailwind CSS v3.3"/>
1420
</div>
@@ -22,9 +28,9 @@ Tailwind CSS v3.3 is here — bringing a bunch of new features people have been
2228
- [New line-height modifier:](#new-line-height-shorthand-for-font-size-utilities) Set your font-size and line-height with one class.
2329
- [CSS variables without the var()](#css-variables-without-the-var): New shorthand syntax for arbitrary values.
2430
- [Configurable `font-variation-settings`:](#configure-font-variation-settings-for-custom-font-families) Baked directly into your `font-*` utilities.
31+
- [New `list-style-image` utilities:](#new-list-style-image-utilities) So you can use horrible clip art for bullet points.
2532
- [New `hyphens` utilities:](#new-hyphens-utilities) For fine-tuning hyphenation behavior.
2633
- [New `caption-side` utilities:](#new-caption-side-utilities) Title your tables with style.
27-
- [New `list-style-image` utilities:](#new-list-style-image-utilities) So you can use horrible clip art for bullet points.
2834

2935
That covers the most exciting stuff, but check out the [release notes](https://github.com/tailwindlabs/tailwindcss/releases/tag/v3.2.0) for an exhaustive list of every single little improvement we've made since the last release.
3036

@@ -40,15 +46,18 @@ You can also try out all of the new features on [Tailwind Play](https://play.tai
4046

4147
<h2 id="extended-color-palette-for-darker-darks">Extended color palette for darker darks</h2>
4248

49+
50+
4351
- Screenshot (or real demo?) some examples of where this is actually useful, show before and after
4452
- Sexy dark UI
4553
- Colored background with colored headline
4654

55+
---
56+
4757
<h2 id="esm-and-typescript-support">ESM and TypeScript support</h2>
4858

49-
- Show an example config file, maybe tabbed example with all three formats?
50-
- Talk about `init` improvements with `--esm` and `--ts` flag, and detecting project type?
51-
- Talk about how it works? Frame it as "we've hesitated to implement because of this but you wanted it so here it is"
59+
Now you can configure Tailwind CSS in ESM, or even in TypeScript:
60+
5261

5362
```js {{ filename: "tailwind.config.js", style: "framed" }}
5463
/** @type {import('tailwindcss').Config} */
@@ -61,23 +70,33 @@ export default {
6170
}
6271
```
6372

64-
```js {{ filename: "tailwind.config.ts", style: "framed" }}
65-
import type { Config } from 'tailwindcss'
73+
When you run `npx tailwindcss init`, we'll detect if your project is an ES Module and automatically generate your config file with the right syntax.
6674

67-
export default {
68-
content: [],
69-
theme: {
70-
extend: {},
71-
},
72-
plugins: [],
73-
} satisfies Config
75+
You can also generate an ESM config file explicitly by using the `--esm` flag:
76+
77+
```sh
78+
npx tailwindcss init --esm
7479
```
7580

81+
To generate a TypeScript config file, use the `--ts` flag:
82+
83+
```sh
84+
npx tailwindcss init --ts
85+
```
86+
87+
A lot of people assume this is easy because they're writing their own code in ESM already (even if it's being transpiled by their build tool) but it's actually pretty tricky — we literally have to transpile the config file for you on the fly.
88+
89+
It's a bit easier to understand why this has to happen when you think of the TypeScript case, because of course Tailwind is distributed as JavaScript, and it can't magically import an uncompiled TypeScript file.
90+
91+
We're handling this with the wonderful [jiti](https://github.com/unjs/jiti) library under the hood, and using [Sucrase](https://github.com/alangpierce/sucrase) to transpile the code with the best possible performance while keeping the installation footprint small.
92+
93+
---
7694

7795
<h2 id="simplified-rtl-support-with-logical-properties">Simplified RTL support with logical properties</h2>
7896

79-
- Demo of `ps-4` or something, showing the LTR and RTL design side by side
80-
- Show `pl-4 rtl:pr-4` as the old solution?
97+
We've made it possible to style multi-directional websites using our [LTR and RTL variants](https://tailwindcss.com/docs/hover-focus-and-other-states#rtl-support) for a while, but now you can use [logical properties](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Logical_Properties/Basic_concepts) to do most of this styling more easily and automatically.
98+
99+
Using new utilities like `ms-3` and `me-3`, you can style the _start_ and _end_ of an element so that your styles automatically adapt in RTL, instead of writing code like `ltr:ml-3 rtl:mr-3`:
81100

82101
<Example>
83102
<div class="grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-10 max-w-lg mx-auto">
@@ -115,12 +134,41 @@ export default {
115134
</div>
116135
```
117136

118-
<h2 id="line-clamp-out-of-the-box">Line-clamp out of the box</h2>
137+
We've added new logical property utilities for [inset](/docs/top-right-bottom-left), [margin](/docs/margin), [padding](/docs/padding), [border-radius](/docs/border-radius), [scroll-margin](/docs/scroll-margin), and [scroll-padding](/docs/scroll-padding).
138+
139+
Here's a full list of all of the new utilities we've added and what they map to:
140+
141+
| New class | Properties | Physical counterpart (LTR) |
142+
| -------------- | --------------------------------------------------------- | -------------------------- |
143+
| `start-*` | `inset-inline-start` | `left-*` |
144+
| `end-*` | `inset-inline-end` | `right-*` |
145+
| `ms-*` | `margin-inline-start` | `ml-*` |
146+
| `me-*` | `margin-inline-end` | `mr-*` |
147+
| `ps-*` | `padding-inline-start` | `pl-*` |
148+
| `pe-*` | `padding-inline-end` | `pr-*` |
149+
| `rounded-s-*` | `border-start-start-radius`<br/>`border-end-start-radius` | `rounded-l-*` |
150+
| `rounded-e-*` | `border-start-end-radius`<br/>`border-end-end-radius` | `rounded-l-*` |
151+
| `rounded-ss-*` | `border-start-start-radius` | `rounded-tl-*` |
152+
| `rounded-se-*` | `border-start-end-radius` | `rounded-tr-*` |
153+
| `rounded-ee-*` | `border-end-end-radius` | `rounded-br-*` |
154+
| `rounded-es-*` | `border-end-start-radius` | `rounded-bl-*` |
155+
| `border-s-*` | `border-inline-start-width` | `border-l-*` |
156+
| `border-e-*` | `border-inline-end-width` | `border-r-*` |
157+
| `border-s-*` | `border-inline-start-color` | `border-l-*` |
158+
| `border-e-*` | `border-inline-end-color` | `border-r-*` |
159+
| `scroll-ms-*` | `scroll-margin-inline-start` | `scroll-ml-*` |
160+
| `scroll-me-*` | `scroll-margin-inline-end` | `scroll-mr-*` |
161+
| `scroll-ps-*` | `scroll-padding-inline-start` | `scroll-pl-*` |
162+
| `scroll-pe-*` | `scroll-padding-inline-end` | `scroll-pr-*` |
163+
164+
These should save you a ton of code if you regularly build sites that need to support both LTR and RTL languages, and you can always combine these with the `ltr` and `rtl` variants when you need more control.
119165

120-
<!-- ![](./2023-03-22-16-32-33.png) -->
121166

122-
- Demo with blog section thing on top, code below
123-
- Mention removing it from your config obviously if you have it installed
167+
---
168+
169+
<h2 id="line-clamp-out-of-the-box">Line-clamp out of the box</h2>
170+
171+
We released our [official line-clamp plugin](https://tailwindcss.com/blog/multi-line-truncation-with-tailwindcss-line-clamp) just over two years ago and even though it uses a bunch of weird deprecated `-webkit-*` stuff, it works in every browser and it's going to work forever, so we decided to just bake it into the framework itself.
124172

125173
<Example p="none">
126174
<div class="px-4 sm:px-0">
@@ -158,91 +206,108 @@ export default {
158206
</article>
159207
```
160208

209+
So when you upgrade to v3.3, you can safely remove the line-clamp plugin if you were using it:
161210

162-
<h2 id="new-line-height-shorthand-for-font-size-utilities">New line-height shorthand for font-size utilities</h2>
211+
```diff-js tailwind.config.js
212+
module.exports = {
213+
// ...
214+
plugins: [
215+
- require('@tailwindcss/line-clamp')
216+
]
217+
}
218+
```
163219

164-
- Just a code demo, show the diff between the old way and new way
165-
- While ago introduced color opacity modifier, got to thinking where else could we improve the authoring experience using modifiers?
166-
- Explain found ourselves literally never changing the line-height without changing the font-size, so why not change them together and use a shorter syntax
167-
- Inspired by `font` property syntax (`font: small-caps bold 24px/1 sans`)
220+
Don't let the door hit you in the ass on the way out, plugin.
168221

169-
<Example>
170-
<div class="flex flex-col gap-8">
171-
<div>
172-
<span class="font-medium text-sm text-slate-500 font-mono mb-3 dark:text-slate-400">text-base/6</span>
173-
<p class="text-base/6 text-slate-900 dark:text-slate-200">
174-
So I started to walk into the water. I won't lie to you boys, I was terrified. But I pressed on, and as I made my way past the breakers a strange calm came over me. I don't know if it was divine intervention or the kinship of all living things but I tell you Jerry at that moment, I <em>was</em> a marine biologist.
175-
</p>
176-
</div>
177-
<div>
178-
<span class="font-medium text-sm text-slate-500 font-mono mb-3 dark:text-slate-400">text-base/7</span>
179-
<p class="text-base/7 text-slate-900 dark:text-slate-200">
180-
So I started to walk into the water. I won't lie to you boys, I was terrified. But I pressed on, and as I made my way past the breakers a strange calm came over me. I don't know if it was divine intervention or the kinship of all living things but I tell you Jerry at that moment, I <em>was</em> a marine biologist.
181-
</p>
182-
</div>
183-
<div>
184-
<span class="font-medium text-sm text-slate-500 font-mono mb-3 dark:text-slate-400">text-base/loose</span>
185-
<p class="text-base/loose text-slate-900 dark:text-slate-200">
186-
So I started to walk into the water. I won't lie to you boys, I was terrified. But I pressed on, and as I made my way past the breakers a strange calm came over me. I don't know if it was divine intervention or the kinship of all living things but I tell you Jerry at that moment, I <em>was</em> a marine biologist.
187-
</p>
188-
</div>
189-
</div>
190-
</Example>
222+
Check out the new [line-clamp documentation](/docs/line-clamp) to learn more about it all works if you haven't played with it before.
191223

224+
---
192225

193-
```html
194-
<p class="**text-base/6** ...">So I started to walk into the water...</p>
195-
<p class="**text-base/7** ...">So I started to walk into the water...</p>
196-
<p class="**text-base/loose** ...">So I started to walk into the water...</p>
226+
<h2 id="new-line-height-shorthand-for-font-size-utilities">New line-height shorthand for font-size utilities</h2>
227+
228+
One thing we've found over years and years of designing beautiful stuff with Tailwind is that we literally _never_ set a line-height without also setting the font-size at the same time.
229+
230+
So inspired by our color opacity modifier syntax, we decided to make it possible to save a few characters by setting them together with a single utility:
231+
232+
```diff-html {{ filename: 'index.html', style: 'framed' }}
233+
- <p class="**text-lg leading-7** ...">
234+
+ <p class="**text-lg/7** ...">
235+
So I started to walk into the water. I won't lie to you boys, I was terrified. But
236+
I pressed on, and as I made my way past the breakers a strange calm came over me.
237+
I don't know if it was divine intervention or the kinship of all living things but
238+
I tell you Jerry at that moment, I <em>was</em> a marine biologist.
239+
</p>
197240
```
198241

199-
You can use any value defined in your [line-height scale](/docs/line-height), or use arbitrary values if you need to deviate from your design tokens.
242+
You can use any value defined in your [line-height scale](/docs/line-height), or use arbitrary values if you need to deviate from your design tokens:
200243

201244
```html
202245
<p class="text-sm**/[17px]** ..."></p>
203246
```
204247

205-
<h2 id="css-variables-without-the-var">CSS variables without the var()</h2>
248+
Check out the [font size documentation](/docs/font-size#setting-the-line-height) for a few more examples.
206249

207-
- Code demo showing the syntax
250+
---
208251

209-
```html
210-
<div class="bg-[${company.brandColor}]">
252+
<h2 id="css-variables-without-the-var">CSS variables without the var()</h2>
211253

212-
<div style="--brand-color: ${company.brandColor}; --brand-hover-color: ${company.brandHoverColor}" class="bg-[--brand-color] hover:bg-[--brand-hover-color]">
254+
In the spirit of typing less, we've also made it possible to omit the `var()` when using a CSS variable as an arbitrary value:
255+
256+
```diff-jsx {{ style: 'framed', filename: 'my-component.jsx' }}
257+
export function MyComponent({ company }) {
258+
return (
259+
<div
260+
style={{
261+
'--brand-color': ${company.brandColor},
262+
'--brand-hover-color': ${company.brandHoverColor},
263+
}}
264+
- className="bg-[var(--brand-color)] hover:bg-[var(--brand-hover-color)]"
265+
+ className="bg-[--brand-color] hover:bg-[--brand-hover-color]"
266+
/>
267+
)
268+
}
213269
```
214270

215-
<h2 id="configure-font-variation-settings-for-custom-font-families">Configure <code className="font-[number:inherit] font-[inherit] text-[length:inherit]">font-variation-settings</code> for custom font families</h2>
271+
That's a pretty cool trick right there for using things like `hover:` with styles that come from the database or something by the way.
216272

217-
- Example Inter Display
218-
- Explain wtf `font-variation-settings` even is, give example of how Inter kinda ships multiple fonts in one file by taking advantage of this feature
219-
- Now any time you use the `font-sans` utility, your font-variation-settings configuration will automatically be applied.
273+
---
220274

221-
```
222-
module.exports = {
223-
theme: {
224-
fontFamily: {
225-
sans: [
226-
'Inter var, sans-serif',
227-
{
228-
fontFeatureSettings: '"cv11", "ss01"',
229-
fontVariationSettings: '"opsz" 32',
230-
},
231-
],
275+
<h2 id="configure-font-variation-settings-for-custom-font-families">Configure <code className="font-[number:inherit] font-[inherit] text-[length:inherit]">font-variation-settings</code> for custom font families</h2>
276+
277+
When using custom fonts, you'll often want to configure things like `font-feature-settings` or `font-variation-settings` to opt-in to specific tweaks the font offers.
278+
279+
We've made it easy to do this for `font-feature-settings` for a while, but now you can do the same thing with `font-variation-settings` by providing a value for it in the sort-of options object you can plop after the font list in your config file:
280+
281+
```js {{ filename: 'tailwind.config.js', style: 'framed' }}
282+
module.exports = {
283+
theme: {
284+
fontFamily: {
285+
sans: [
286+
'Inter var, sans-serif',
287+
> {
288+
> fontFeatureSettings: '"cv11", "ss01"',
289+
> fontVariationSettings: '"opsz" 32',
290+
> },
291+
],
292+
},
232293
},
233-
},
234-
}
294+
}
235295
```
236296

297+
---
298+
299+
<h2 id="new-list-style-image-utilities">New <code className="font-[number:inherit] font-[inherit] text-[length:inherit]">list-style-image</code> utilities</h2>
300+
301+
- Demo from docs (checkmark?)
302+
303+
---
237304

238305
<h2 id="new-hyphens-utilities">New <code className="font-[number:inherit] font-[inherit] text-[length:inherit]">hyphens</code> utilities</h2>
239306

240307
- Demo from docs
241308

309+
---
310+
242311
<h2 id="new-caption-side-utilities">New <code className="font-[number:inherit] font-[inherit] text-[length:inherit]">caption-side</code> utilities</h2>
243312

244313
- Demo from docs
245-
246-
<h2 id="new-list-style-image-utilities">New <code className="font-[number:inherit] font-[inherit] text-[length:inherit]">list-style-image</code> utilities</h2>
247-
248-
- Demo from docs (checkmark?)

0 commit comments

Comments
 (0)