@weapp-tailwindcss/reset
@weapp-tailwindcss/reset is an independent reset resource package, suitable for direct import in the entry style of the uni-app / Taro project, and can also be used directly as a Tailwind plug-in.
It now provides both capabilities:
- Static style file collection, directly
import '@weapp-tailwindcss/reset/xxx.css' - Tailwind plug-in entry, inject base rules through
reset({...})or@plugin
In order to be compatible with old projects, weapp-tailwindcss/reset still retains the export; but the new plug-in implementation has been moved to @weapp-tailwindcss/reset.
Install
- npm
- Yarn
- pnpm
- Bun
npm install -D @weapp-tailwindcss/reset
yarn add --dev @weapp-tailwindcss/reset
pnpm add -D @weapp-tailwindcss/reset
bun add --dev @weapp-tailwindcss/reset
Currently provided reset
| Path | Description | Applicable scenarios |
|---|---|---|
normalize.css | Cross-end static version of normalize.css | Conservative, close to browser default behavior |
modern-normalize.css | Cross-end static version of modern-normalize | Want a more modern, lightweight baseline |
eric-meyer.css | Classic Eric Meyer reset | Need a strong reset and completely take over the basic style yourself |
sanitize/sanitize.css | ||
sanitize/assets.css | Supplementary resource size constraints for sanitize.css | Used in conjunction with the above |
tailwind.css | Static version of Tailwind preflight | Want to directly use Tailwind style reset |
Used as a Tailwind plug-in
import reset from '@weapp-tailwindcss/reset'
export default {
plugins: [
reset({
preset: 'all',
listReset: false,
}),
],
}
By default, the plugin remains compatible with the old behavior and only injects button and image. If you want to open more built-in resets in batches, you can use:
preset: 'form'preset: 'content'preset: 'media'preset: 'all'
Built-in resets for additional control include:
inputResettextareaResetlistResetnavigatorResetvideoReset
If you are already using weapp-tailwindcss/reset in your project, there is no need to migrate; the behavior of the two remains the same, but the actual implementation now belongs to this package.
uni-app usage
Typically imported in src/main.ts, App.vue or global entry styles:
import '@weapp-tailwindcss/reset/uni-app/button-after.css'
import '@weapp-tailwindcss/reset/uni-app/tailwind-compat.css'
If you use sanitize.css, you usually need to import both files together:
import '@weapp-tailwindcss/reset/uni-app/sanitize/sanitize.css'
import '@weapp-tailwindcss/reset/uni-app/sanitize/assets.css'
Taro usage
Usually imported in src/app.tsx or entry style:
import '@weapp-tailwindcss/reset/taro/button-after.css'
import '@weapp-tailwindcss/reset/taro/tailwind-compat.css'
Select suggestions
- The component library has been used in the project, priority is given to
button-after.css + tailwind-compat.css - If you want to be close to Tailwind's default preflight, select
tailwind.css - If you want to be more conservative, choose
modern-normalize.cssornormalize.css - If you want to forcefully clear the default style, select
eric-meyer.css - For more complete default security values and resource constraints, select
sanitize/sanitize.css + sanitize/assets.css
Typical combination
import '@weapp-tailwindcss/reset/uni-app/button-after.css'
import '@weapp-tailwindcss/reset/uni-app/tailwind-compat.css'
The above group is usually suitable for projects with component libraries.
import '@weapp-tailwindcss/reset/taro/modern-normalize.css'
The above group is usually suitable for projects that just want to add a lightweight global baseline.
Relationship with the main package style
@weapp-tailwindcss/reset will not replace the main package products weapp-tailwindcss/index.css and preflight.css. It is more like an "optional reset warehouse" that allows you to decide which set of baseline styles to import at the entrance.
If you are already using weapp-tailwindcss/index.css, whether you want to introduce additional resets here needs to be decided based on your project baseline and component library compatibility. It is not recommended to stack multiple sets of resets without thinking.