Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
A "reset" for your Tailwind config that enforces best practices, improves rendering performance, and reduces bundle size.
A "reset" for your Tailwind config that enforces best practices, improves rendering performance, and reduces bundle size.
🤔 Why would I want this?
Tailwind v3's default config includes a bunch of stuff that the authors wanted to change but couldn't because of backwards compatibility (i.e. deprecated flex-shrink
utilities, unexpected content
path behavior). Tailwind v4 will address all of these, but in the meantime you can modernize & future-proof your existing v3 sites with tw-reset
, while reaping some performance benefits and bundle size reductions.
Install the plugin from npm:
npm install -D tw-reset
Then add the preset to your tailwind.config.js
file:
module.exports = {
+ presets: [require('tw-reset')],
// ...
}
[!IMPORTANT] If you're using CSS Modules or
<style>
tags in Vue/Svelte, pass this option to the preset:presets: [ require('tw-reset')({ optimizeUniversalDefaults: false }) ]
Read the first section below for more information.
By default, Tailwind outputs the following rule to prevent internal CSS variables from inheriting. You may have seen it in your inspector at some point:
*,
::before,
::after {
--tw-border-spacing-x: 0;
--tw-border-spacing-y: 0;
--tw-translate-x: 0;
--tw-translate-y: 0;
--tw-rotate: 0;
--tw-skew-x: 0;
/* ... */
}
This works, but it's inefficient as it applies to every element on the page even though the variables are only needed in their corresponding utilities.
An alternative strategy is available behind an experimental config flag, which optimizes this output and likely improves the rendering performance of your site:
https://github.com/barvian/tw-reset/assets/868352/39ca9c8c-6ac8-40d3-b97a-3be069a78541
This flag is currently used in production on tailwindcss.com and was initially considered for the default config in Tailwind v3, but was ruled out because it doesn't work with "per-component styles" that cause PostCSS to run multiple times in isolation (i.e. Vue/Svelte <style>
tags or CSS Modules). However, Tailwind discourages per-component styles, so tw-reset
enables this flag by default, which enforces best practices and brings the other improvements mentioned.
If you must use per-component styles, you can disable this flag with:
// tailwind.config.js
module.exports = {
presets: [
require('tw-reset')({
optimizeUniversalDefaults: false
})
]
}
Tailwind v4 will support container queries out-of-the-box, so tw-reset
includes the official container query plugin that uses the same syntax as Tailwind v4. If you were previously using this plugin, make sure you remove it when adding tw-reset
:
module.exports = {
+ presets: [require('tw-reset')],
plugins: [
- require('@tailwindcss/container-queries')
]
}
Tailwind currently ships with a few deprecated utilities that still show up in IntelliSense suggestions:
flex-shrink
(replaced by shrink
)flex-grow
(replaced by grow
)overflow-ellipsis
(replaced by text-ellipsis
)decoration-slice
(replaced by box-decoration-slice
)decoration-clone
(replaced by box-decoration-clone
)These deprecated utilities will be removed in Tailwind v4, so they're disabled by default in tw-reset
and hidden from IntelliSense.
Tailwind v4 will change the default border and ring colors to currentColor
, which is the browser default. It will also use 1px
as the default ring width, and 100%
as the default ring opacity. tw-reset
implements all these changes, which future-proofs your site for Tailwind v4 and provides more predictable behavior.
*-opacity
utilities disabled by defaultOlder versions of Tailwind used *-opacity
classes to change the opacity of colors, i.e.
<h1 class="text-black text-opacity-50">...</h1>
These utilities have been removed from Tailwind documentation, replaced by the newer opacity modifier syntax. They'll be disabled by default in Tailwind v4, so tw-reset
also disables them by default. This has the pleasant side effect of slightly reducing your CSS bundle size and simplifying the color output:
.border-white {
- --tw-border-opacity: 1;
- border-color: rgb(255 255 255 / var(--tw-border-opacity));
+ border-color: #fff;
}
.bg-white {
- --tw-bg-opacity: 1;
- background-color: rgb(255 255 255 / var(--tw-bg-opacity));
+ background-color: #fff;
}
.text-white {
- --tw-text-opacity: 1;
- color: rgb(255 255 255 / var(--tw-text-opacity));
+ color: #fff;
}
rem
Tailwind v4 will use rem
units for its default breakpoints, which better complement the default font sizes and spacing scales that also use rem
. This was initially considered for Tailwind v1, but was ruled out due to Safari bugs at the time. Those bugs have since been fixed, so tw-reset
provides rem
-based breakpoints as default. This shouldn't cause any changes to your design if you're using Tailwind's default px
-based breakpoints.
If you need to refer to these new breakpoints in your code for some reason, you can import them like so:
const { screens } = require('tw-reset/defaultTheme')
tw-reset
resolves non-absolute content paths relative to the config file (rather than the current working directory), which "will likely become the default" in Tailwind v4.
FAQs
A "reset" for your Tailwind config that enforces best practices, improves rendering performance, and reduces bundle size.
The npm package tw-reset receives a total of 396 weekly downloads. As such, tw-reset popularity was classified as not popular.
We found that tw-reset demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.