@acab/reset.css

中文文档
0.11.0发布于 2024/11/29ES Module零依赖近 30 天下载 7223

a modern css reset for 2024 and beyond

原始使用文档
文档目录6 节
  1. Features
  2. Usage
  3. Cascade layers
  4. Visually hidden (aka SR only)
  5. Focus outlines
  6. Acknowledgements

reset.css

A style reset that embraces modern CSS features to give you a better base to start off with.

Features

  • Designed for cascade layers while still using :where to keep a low specificity for unlayered setups.
  • Auto dark mode using color-scheme.
  • system-ui font pre-applied.
  • Accessible, consistent focus outlines.
  • Supports new features like <dialog> and popover.
  • .visually-hidden class baked in.

See the source code if you're curious about the full set of rules.

Usage

Install and import the package (requires a bundler):

npm install @acab/reset.css
/* in a CSS file or <style> tag */
@import '@acab/reset.css';
// or in a JS file
import '@acab/reset.css';

Or use it directly from a CDN:

@import 'https://unpkg.com/@acab/reset.css';

Cascade layers

It is recommended to import this reset into the very first layer.

Ideally, you should predefine your layers as the first thing in the first stylesheet.

@layer reset, page, overrides;

And then apply the first layer name while importing this reset.

@import '@acab/reset.css' layer(reset);

Visually hidden (aka SR only)

Every project needs "visually hidden" styles for screenreader-only text, so this reset has it built in.

It's available through the .visually-hidden class and all the declarations in it use !important so that they can't be overridden by a higher-priority layer.

When a visually-hidden element is focused or an element inside it is focused, then these styles will automatically be undone.

Focus outlines

By default, focus styles can be very inconsistent (and even inaccessible) across browsers. This reset normalizes them to a dual color outline that uses system colors which adopt with the color-scheme. Depending on the background within a particular section, you might want to set the color-scheme property to maintain enough color contrast.

To override the focus styles, you can specify your own outline (or just outline-color).

@layer globals {
  :focus-visible {
    outline-color: var(--my-brand);
  }
}

Acknowledgements

This project was inspired by some of the existing, popular CSS resets:

版本与发布记录

@acab/reset.css 共发布 19 个版本,首次发布于 2022/10/17;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.11.0latest2024/11/291.9 年前
0.10.02024/05/162 年前
0.9.02024/04/132 年前
0.8.02023/09/273 年前
0.7.02023/09/043 年前
0.6.02023/08/033 年前

关于 @acab/reset.css 的常见问题

@acab/reset.css 是什么?

a modern css reset for 2024 and beyond

如何安装 @acab/reset.css?

在项目目录运行 npm install @acab/reset.css,或使用 pnpm add / yarn add / bun add。

@acab/reset.css 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/acab__reset.css 是否存在。

@acab/reset.css 支持 ESM 还是 CommonJS?

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

@acab/reset.css 可以商用吗?

@acab/reset.css 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@acab/reset.css 的下载量有多少?

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

@acab/reset.css 还在维护吗?

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