@cssints/reset

中文文档
0.35.1发布于 2026/11/07MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 7375

A small modern CSS reset for cssints, in a layer below every style

原始使用文档
文档目录4 节
  1. The rules
  2. Baseline variants
  3. Limits
  4. Credits

@cssints/reset

A small modern CSS reset for cssints, in a layer below every other style of the sheet, so any style beats it whatever its specificity. It is one call member of cssints/plugin scope() that returns global rules. No runtime.

import { reset } from "@cssints/reset" with { type: "cssints" };

// reset({ media?, prose? })
reset({ media: true, prose: true });
@layer reset;
@layer _.k, _.a, _.b, _.c, _.d, _.e;
@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }
  * {
    margin: 0;
  }
  html {
    -webkit-text-size-adjust: none;
    text-size-adjust: none;
    line-height: 1.5;
  }
  :where(input, button, textarea, select) {
    font: inherit;
    letter-spacing: inherit;
    word-spacing: inherit;
    color: inherit;
  }
  :where(button, input[type="button"], input[type="submit"], input[type="reset"]) {
    border: 0;
  }
  :where(p, h1, h2, h3, h4, h5, h6) {
    overflow-wrap: break-word;
  }
  :where(h1, h2, h3, h4, h5, h6) {
    text-wrap: balance;
  }
  :where(p) {
    text-wrap: pretty;
  }
  :where(ul, ol)[role="list"] {
    list-style: none;
    padding: 0;
  }
}
/* prose: true */
@layer reset {
  :where(h1, …, p, ul, ol, dl, blockquote, pre, figure, table, hr):not([class])
    + :where(h1, …, hr):not([class]) {
    margin-block-start: 1em;
  }
  :where(h1, h2, h3, h4, h5, h6):not([class]) {
    line-height: 1.25;
  }
}
/* media: true */
@layer reset {
  :where(img, picture, video, canvas, svg) {
    display: block;
    max-inline-size: 100%;
  }
  :where(img, video) {
    block-size: auto;
  }
}

The rules

  • The base is what most modern resets agree on (Josh Comeau, Jake Lazaroff, Vale): border-box, no margins, a readable line height, no text inflation on mobile, form controls in the page's font and colour, buttons without the border of the browser (its bevel; text fields, text areas and selects keep theirs), long words that wrap, balanced headings and paragraphs without orphans. A button keeps the background and the padding of the browser (Tailwind's preflight drops the background; this reset does not). The paddings stay (a list keeps room for its markers), and the markers of a list go only with role="list" (Andy Bell's), since Safari stops announcing a list that has list-style: none.
  • media: true makes images, videos, canvases and SVGs blocks that never overflow their container, and keeps the aspect ratio of an image or video whose height attribute is set.
  • prose: true adds back the space of text: 1em between flow elements that follow each other (Andy Bell's flow), and tighter headings, only on elements that have no class (Jake Lazaroff's :not([class])), as in rendered Markdown. An element with a cssints class is left alone.
  • Below everything. The rules are in a top-level layer reset, declared before the engine's layers (a layers entry with before: true), so the reset is below the kernels, global() and token rules of _.k, below the class layers and the layers you declare with layers(); an unlayered stylesheet beats it as well.
  • A layer of your own between. Declare it after reset, before the engine's: layers("reset", "base", { before: true }) puts base above the reset and below every cssints style.
  • Once. Each block is a global rule identified by its text: reset() in two modules, or reset() and reset({ media: true }), print the base once.

Baseline variants

@cssints/reset is the whole reset. @cssints/reset/<group> is the same call with the declarations of a Baseline group of cssints only (inGroup of cssints/plugin, from the group data of cssints): widely-available, newly-available, baseline-2015 to baseline-2026 (what was Baseline at the end of that year), and each of them /with-downstream (also checked against Opera, Samsung Internet, Android WebView, UC and QQ). A declaration whose property or value the group does not have is left out, and a rule left with no declaration goes. limited-availability is everything, as @cssints/reset. not-discouraged has no variant: it bans three properties and four keywords that the reset does not use. A name that is no Baseline group is a type error.

import { reset } from "@cssints/reset/widely-available" with { type: "cssints" };

reset({ media: true, prose: true });

What each variant drops (written by node test/reset.mjs --write, checked by bun run test):

DroppedVariants
nothinglimited-availability
text-size-adjust: none, text-wrap: balance, text-wrap: prettywidely-available, widely-available/with-downstream, baseline-2020, baseline-2020/with-downstream, baseline-2021, baseline-2021/with-downstream, baseline-2022, baseline-2022/with-downstream, baseline-2023, baseline-2023/with-downstream
text-size-adjust: none, text-wrap: prettynewly-available, newly-available/with-downstream, baseline-2024, baseline-2024/with-downstream, baseline-2025, baseline-2025/with-downstream, baseline-2026, baseline-2026/with-downstream
text-size-adjust: none, overflow-wrap: break-word, text-wrap: balance, text-wrap: pretty, margin-block-start: 1em, max-inline-size: 100%, block-size: autobaseline-2015, baseline-2015/with-downstream, baseline-2016, baseline-2016/with-downstream, baseline-2017, baseline-2017/with-downstream
text-size-adjust: none, text-wrap: balance, text-wrap: pretty, margin-block-start: 1em, max-inline-size: 100%, block-size: autobaseline-2018, baseline-2018/with-downstream, baseline-2019, baseline-2019/with-downstream

A dropped declaration is not replaced. text-wrap: balance and pretty are progressive: without them a heading wraps as it always did. The unprefixed text-size-adjust is only for browsers that do not read -webkit-text-size-adjust, which every variant keeps (a property cssints has no member for is in every group).

Limits

  • The selectors are not checked. The group data has the pseudo-classes without arguments (:hover), and no functional pseudo-class (:where(), :not()), pseudo-element (::before, ::backdrop), attribute selector or combinator. A variant keeps every selector as written, so baseline-2015 to baseline-2020 keep rules with :where() (Baseline 2021) and :not() with a selector list, and drop only their declarations.

  • reset is a contract name: a layers("reset") without before, or another plugin that declares reset after the engine's layers, is a build error.

  • The rule set is fixed: there is no option per rule. A rule you do not want is overridden by any style of yours.

  • Call it at a module's top level, in a module that the pages load (the entry): the reset is in the sheet of the modules that call it, and leaves with them.

cd packages/reset && bun run test   # fixtures through the engine (the order of the sheet, the flags, each variant), and the type test via bun run typecheck
cd packages/reset && bun run variants   # rewrite src/groups after a bun run groups in packages/cssints

Credits

The base follows what Josh Comeau, Jake Lazaroff and Vale publish; role="list" and the flow rule are Andy Bell's. The declarations are those that these resets share. They are written here, as globals of scope(); no file is copied.

版本与发布记录

@cssints/reset 共发布 43 个版本,首次发布于 2026/10/11;过去 12 个月发布了 43 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.35.1latest2026/11/073 天前
0.35.02026/11/073 天前
0.34.02026/11/073 天前
0.33.02026/11/046 天前
0.32.02026/11/046 天前
0.31.02026/11/047 天前

关于 @cssints/reset 的常见问题

@cssints/reset 是什么?

A small modern CSS reset for cssints, in a layer below every style

如何安装 @cssints/reset?

在项目目录运行 npm install @cssints/reset,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:cssints(^0.35.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@cssints/reset 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@cssints/reset 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@cssints/reset 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@cssints/reset 可以商用吗?

@cssints/reset 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@cssints/reset 的下载量有多少?

根据 npm 官方下载统计,@cssints/reset 在 2026/10/11 – 2026/11/09 这 30 天内被下载 7,375 次,日均约 246 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cssints/reset 还在维护吗?

最新版本 0.35.1 发布于 2026/11/07(3 天前);至今共发布 43 个版本,其中过去 12 个月发布了 43 个;首次发布于 2026/10/11。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。