TailwindCSS v2.0


Practically exactly 18 months in the past we released Tailwind CSS v1.0, which signalled a commitment to balance whereas continuing to push the boundaries with thrilling current factors in every minor unlock.

Over the course of these 18 months we released 9 minor versions that added factors like placeholder styling, screenreader visibility, CSS grid, transitions, transforms, animations, structure utilities, integrated tree-shaking, gradients, and loads more.

This present day we’re in the end releasing Tailwind CSS v2.0.

Tailwind CSS v2.0 is the first predominant change ever, including:

  • All-current coloration palette, that comprises 220 total colours and a current workflow for building your own coloration schemes
  • Dusky mode enhance, making it more straightforward than ever to dynamically alternate your create when sad mode is enabled
  • Extra huge 2XL breakpoint, for designing at 1536px and above
  • Novel account for ring utilities, that are nearly as dependable as in the occasion that they’d dependable make account for-radius a exact thing
  • Utility-beneficial secure styles, a current secure reset that makes it straightforward to customize secure factors (even checkboxes) with dependable utility classes
  • Default line-heights per font-size, attributable to if we can no longer make utilizing a 1.5 line-top with a 48px font illegal we might well maybe also mute no longer decrease than make it no longer the default
  • Prolonged spacing, typography, and opacity scales, for stunning-tuning issues on the micro stage, making an very beneficial higher influence with chunky headlines, and for when opacity-25 wasn’t sufficient and opacity-50 became as soon as too mighty
  • Exhaust @put alongside side one thing else, including responsive, hover, middle of attention, and other variants
  • Novel textual protest overflow utilities, for controlling issues more precisely than that it’s possible you’ll even with truncate alone
  • Lengthen variants, so that it’s possible you’ll even enable further variants like middle of attention-seen without redeclaring your total list or engaging on expose
  • Crew-hover and middle of attention-inner by default, attributable to you had been enabling them on every project anyways
  • Default transition length and easing curve, so you most glorious must add 17 classes to make a button as a change of 19
  • Incompatibility with IE11, so that it’s possible you’ll even converse the actual person upstairs “sorry boss or no longer it’s out of my fingers, blame Tailwind”

…and a bunch of other puny issues too.

Even although Tailwind CSS v2.0 is a current predominant version, we’ve worked actually tough to decrease predominant breaking adjustments, seriously ones that will well maybe power you to edit many of your templates. We’ve renamed two classes, eliminated three that are no longer relevant in neatly-liked browsers, and replaced two with more highly glorious picks. Every other breaking adjustments that will well maybe also influence that it’s possible you’ll even additionally be remedied with a couple tiny additions to your tailwind.config.js file. Upgrading shouldn’t take more than about 30 minutes.

Examine out the upgrade manual for more particulars and step-by-step directions on migrating your project to Tailwind CSS v2.0.

In expose for you to start a tag current project with v2.0, head over to our as much as this point set up documentation to start immediate.

Additionally how about that tag current web region eh? Sizzling rattling.


All-current coloration palette

We’ve realized plenty about coloration for the reason that first time we tried to create a fashioned cause coloration palette again in the Tailwind CSS v0.1.0 days, and v2.0 represents our most glorious are attempting up to now.

The present coloration palette entails 22 colours (in contrast with 10 previously) with 10 shades every (as a change of 9) for a total of 220 values.

New Tailwind CSS color palette

We’ve added an further light 50 coloration for every coloration, so they plug from 50–900 now:

div class="bg-gray-50">I'm capable of no longer judge or no longer it's no longer white.div>

The palette even entails 5 moderately a number of shades of gray now, so that it’s possible you’ll even build close “blue gray” in expose for you one thing actually cool, or plug your total system to “warm gray” for one thing with plenty more brown in it.

New Tailwind CSS alternate gray

We configure a successfully-balanced 8-coloration palette for you out of the sphere, nonetheless your total coloration palette lives in a current tailwindcss/colours module that that it’s possible you’ll even import on the tip of your config file to curate your own custom palette alternatively you like:

// tailwind.config.js
const colours = require('tailwindcss/colours')

module.exports = {
  theme:  {
    colours:  {
      gray:  colours.trueGray,
      indigo:  colours.indigo,
      red:  colours.rose,
      yellow:  colours.amber,
    },
  },
}

Learn more in the current customizing colours documentation.


Dusky mode

Ever since iOS added native sad mode all you sad mode nerds haven’t been ready to head away me alone about adding it to Tailwind. Neatly you potentially did it, or no longer it’s here, you take.

Originate up your tailwind.config.js file and flip darkMode to media:

// tailwind.config.js
module.exports = {
  darkMode:  'media',
  // ...
}

Boost — now dependable add sad: to the starting up of a class like bg-sad and it would most glorious take perform when sad mode is enabled:

div class="bg-white dark:bg-black">
  h1 class="text-gray-900 dark:text-white">Dusky modeh1>
  p class="text-gray-500 dark:text-gray-300">
    The characteristic you own all been attempting forward to.
  p>
div>

Works with hover and stuff too:

button
  class="bg-gray-900 hover:bg-gray-800 dark:bg-white dark:hover:bg-gray-50"
>
  
button>

And responsive stuff:

div class="... lg:bg-white lg:dark:bg-black">
  
div>

And responsive hover stuff:

button class="... lg:dark:bg-white lg:dark:hover:bg-gray-50">
  
button>

Examine out the sad mode doctors for your total gory particulars.


I am moderately sure they make an iPhone that is 1280px huge now, so or no longer it is time to step it up.

We’ve added a current 2xl breakpoint out-of-the-field that lets you aim issues at 1536px and above:

h1 class="... 2xl:text-9xl">Godzillah1>

Thrilling I know nonetheless additionally let’s be severe you had been ready so that you might add this yourself for like three years. Now or no longer it’s blessed although, I secure it.


Novel account for ring utilities

You know how the account for property ignores border radius and moderately mighty dependable constantly appears to be like to be like nasty? The ring utilities are our are attempting to will a higher resolution into existence by blueprint of blood, sweat, and tears.

They work plenty just like the border utilities, excluding they add a stable field-shadow reasonably than a border so they develop no longer influence the structure:

button
  class="... focus:outline-none focus:ring-2 focus:ring-blue-300 focus:ring-opacity-50"
>
  
button>

You might well also even offset them to construct a form of halo perform with ring-offset-{width} utilities:

button
  class="... focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-300 focus:ring-opacity-50"
>
  
button>

Using a bunch of CSS custom property voodoo we’ve even made them robotically mix with current field-shadows, too:

button class="shadow-sm focus:ring-2 ...">
  
button>

The ring width documentation is mainly the most glorious starting up point for learning these current APIs. They seriously turned out so cool, more indispensable than you in all chance mediate.


Utility-beneficial secure styles

One thing I am constantly bowled over by is how few folk complain about how unbelievably ineffective secure factors are out of the sphere with Tailwind. They actually watch bad and that it’s possible you’ll even’t attain one thing else about it without writing custom CSS chunky of unfamiliar background-image SVG solutions and traumatic about vague edge conditions that require CSS properties you own by no methodology heard of earlier than like coloration-alter.

I attempted to treatment this a whereas again with the @tailwindcss/custom-kinds plugin, nonetheless one thing about adding a bunch of classes like secure-enter and secure-checkbox dependable didn’t actually feel moderately worthy so we didn’t actually market it and didn’t even link to it from the Tailwind documentation. This time although I mediate we figured it out.

Alongside Tailwind CSS v2.0, we’re releasing a tag current gracious plugin called @tailwindcss/kinds that normalizes and resets the overall elemental secure controls across browsers to a divulge that is substantial straightforward to model with pure utility classes:


input
  type="checkbox"
  class="h-4 w-4 rounded border-gray-300 focus:border-indigo-300 focus:ring-2 focus:ring-indigo-200 focus:ring-opacity-50 text-indigo-500"
/>

It be no longer included out of the sphere nonetheless that it’s possible you’ll even add it to your tailwind.config.js file with a single line:

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

Examine out the @tailwindcss/kinds documentation for more files.


Default line-heights per font-size

Every font-size utility in Tailwind now comes paired with an very beneficial default line-top:

// Tailwind's default theme
module.exports = {
  theme:  {
    // ...
    fontSize:  {
      xs:  ['0.75rem', { lineHeight: '1rem' }],
      sm:  ['0.875rem', { lineHeight: '1.25rem' }],
      bad:  ['1rem', { lineHeight: '1.5rem' }],
      lg:  ['1.125rem', { lineHeight: '1.75rem' }],
      xl:  ['1.25rem', { lineHeight: '1.75rem' }],
      '2xl':  ['1.5rem', { lineHeight: '2rem' }],
      '3xl':  ['1.875rem', { lineHeight: '2.25rem' }],
      '4xl':  ['2.25rem', { lineHeight: '2.5rem' }],
      '5xl':  ['3rem', { lineHeight: '1' }],
      '6xl':  ['3.75rem', { lineHeight: '1' }],
      '7xl':  ['4.5rem', { lineHeight: '1' }],
      '8xl':  ['6rem', { lineHeight: '1' }],
      '9xl':  ['8rem', { lineHeight: '1' }],
    },
  },
}

So now must you add a utility like textual protest-xl, the corresponding default line-top (1.75rem on this case) is added robotically:

p class="text-xl">This will even own a line-top of 1.75rem robotically.p>

In expose for you to override this, that it’s possible you’ll even mute attain it by layering on a leading utility:

p class="text-3xl leading-normal">Attain on develop no longer attain this to me.p>

Examine out the font size documentation for some further particulars.


Prolonged spacing, typography, and opacity scales

We’ve prolonged the default spacing scale to incorporate a bunch of micro values like 0.5, 1.5, 2.5, and 3.5:

span class="ml-0.5">Proper a puny bit nudge.span>

…as successfully as a bunch of unique values on the tip close as successfully like 72, 80, and 96:

div class="p-96">Here's too mighty padding.div>

We’ve additionally prolonged the inset (that’s top/worthy/bottom/left for you dinosaurs) and translate plugins to incorporate the chunky spacing scale, so now that it’s possible you’ll even attain issues like this:

div class="top-8">
  
div>

We’ve prolonged the default typography scale with current 7xl, 8xl, and 9xl values:

h1 class="text-9xl font-bold">What is that this, an Apple web region?h1>

And we’ve additionally prolonged the default opacity scale with steps of 10, as successfully as 5 and 95 values:

figure class="opacity-5">
  blockquote>You might well no longer leer me.blockquote>
  figcaption>John Cenafigcaption>
figure>

Peep your total default config file to leer exactly what’s available.


Exhaust @put alongside side one thing else

By a ways essentially the most typical query I’ve gotten over time is “why doesn’t @put together hover:bg-sad work?”

And or no longer it’s a stunning query, or no longer it’s dumb that it doesn’t didn’t work.

It took some severe engineering muscle nonetheless we figured it out — now that it’s possible you’ll even @put together actually one thing else:

.btn {
  @put together bg-indigo-500 hover: bg-indigo-600 middle of attention: ring-2 middle of attention: ring-indigo-200 middle of attention: ring-opacity-50;
}

Examine out the as much as this point @put together documentation to learn more.


Novel textual protest overflow utilities

Up till v2.0, in case you wanted to construct a watch on overflowing textual protest all we actually gave you became as soon as the moderately heavy-handed truncate utility.

Now we’ve added devoted overflow-ellipsis and overflow-clip utilities to construct a watch on dependable the textual protest-overflow property, in case you wanted so that you might add ellipsis to overflowing textual protest without limiting that textual protest to one line.

p class="overflow-ellipsis overflow-hidden">
  Watch ma no whitespace-nowrap ipsum...
p>

Examine out the current textual protest overflow documentation to leer it in action.


Lengthen variants

You know what sucks? Making an strive to enable middle of attention-seen for backgroundColor nonetheless having to list every single default variant dependable so that you might add one further one:

// tailwind.config.js
module.exports = {
  // ...
  variants:  {
    backgroundColor:  ['responsive', 'hover', 'focus', 'focus-visible'],
  },
}

You know what’s higher? Proper adding the one you might want to always enable:

// tailwind.config.js
module.exports = {
  // ...
  variants:  {
    delay:  {
      backgroundColor:  ['focus-visible'],
    },
  },
}

Giddy up.


Crew-hover and middle of attention-inner by default

Thought to be one of the issues we realized working on Tailwind UI is that neighborhood-hover and middle of attention-inner are now not tremendous-to-haves, they’re must-haves.

Wherever the build apart we enabled hover or middle of attention by default previously now has neighborhood-hover and middle of attention-inner enabled by default too:

div class="group ...">
  span class="group-hover:text-blue-600 ...">Da ba dee da ba daaspan>
div>

Examine out the default variants reference for a chunky list of what’s enabled the build apart in v2.0.


Default transition length and easing curve

Until now, any time you wanted so that you might add a transition in Tailwind you on the total wanted so that you might add three classes:

button class="... transition duration-150 ease-in-out">Depend thembutton>

In v2.0, we’ve made it that that it’s possible you’ll even accept as true with to specify a default length and timing characteristic that is frail robotically any time any transitionProperty utility is added:

// tailwind.config.js
module.exports = {
  // ...
  theme:  {
    // ...
    transitionDuration:  {
      DEFAULT:  '150ms',
      // ...
    },
    transitionTimingFunction:  {
      DEFAULT:  'cubic-bezier(0.4, 0, 0.2, 1)',
      // ...
    },
  },
}

So now you most glorious must write a single class in case you own a fashioned length and timing characteristic that you make train of actually customarily:

button class="... transition">Depend them againbutton>

Of cours

!–>!–>

Read More

Recent Content