• Stars
    star
    310
  • Rank 134,926 (Top 3 %)
  • Language
    CSS
  • Created about 2 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

a css reset for 2024 and beyond.

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.
  • .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 3px solid outline that has the Highlight color. The is a system color that adopts 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:

More Repositories

1

ecsstatic

the predefinite CSS-in-JS library for vite
TypeScript
264
star
2

astro-css-in-js-tests

Examples of using various CSS-in-JS libs in Astro (repo for withastro/astro#4432)
TypeScript
22
star
3

open-props-scss

open-props as sass variables
JavaScript
20
star
4

live-announcer

web component that makes it easier to work with live regions
JavaScript
16
star
5

tabs

accessible, unstyled, API-less tabs
HTML
13
star
6

postcss-use-logical

auto convert physical CSS properties to logical ones
JavaScript
12
star
7

vite-plugin-webc

JavaScript
12
star
8

riffs

a web app for clipping parts of a song
TypeScript
11
star
9

astro-vercel-edge

Deploy Astro v4 on Vercel Edge Functions
JavaScript
9
star
10

tooltip-element

an accessible tooltip web component built using popover API and floating-ui
JavaScript
8
star
11

webc-astro-demo

webc + astro = πŸ’œ
Astro
8
star
12

wordel

a more accessible wordle clone built using preact
TypeScript
6
star
13

programming-languages

Course content for CS 403
Scheme
4
star
14

11ty-jsx-deno

TypeScript
3
star
15

astro-minimal-starter

An opinionated minimal starter template for astro with prettier, tsconfig aliases, dark theme, and a basic css reset
Astro
2
star
16

enhance-demo

CSS
2
star
17

visually-hidden

Inclusively hide content using a custom element.
JavaScript
2
star
18

11ty-webc-starter

A barebones starter template using the latest canary of 11ty and WebC
JavaScript
2
star
19

open-styleable

experimental server+client "polyfill" for openly styling shadow-roots
HTML
2
star
20

astro-form-progressive

TypeScript
2
star
21

remix-djent-stack

Remix stack with basic postcss-preset-env, code formatting, linting etc
JavaScript
2
star
22

do-transitions

view transitions + FLIP animation fallback
HTML
2
star
23

astro-api-starter

A starter template for deploying Astro SSR API routes to Vercel
Astro
1
star
24

tokencss-linaria-demo

Astro
1
star
25

remix-vite-test

TypeScript
1
star
26

declarative-shadow-dom

Use declarative shadow DOM inside frameworks
TypeScript
1
star
27

lyrica

A PWA that uses Web Share Target for quickly finding song lyrics
HTML
1
star
28

astro-layers-demo

A fun demo showcasing cascade layers in astro
Astro
1
star
29

x-flip-demo

TypeScript
1
star