npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

css-preflight

v1.1.1

Published

CSS browser reset based on Tailwind's preflight, with optional enhancements.

Downloads

94

Readme

CSS Preflight

npm License: MIT

This is a CSS browser reset based on Tailwind's preflight, optimized for non-Tailwind projects. Optional enhancements like smooth scrolling and other utilities are also provided (see usage).

Preflight

The following adjustments have been made to Tailwind's preflight, located in styles/preflight.css:

  1. Tailwind-specific CSS variables removed.
  2. Tailwind postcss functions like theme() removed.
  3. Vendor prefixes (e.g. -webkit-, -moz-) from css properties have been removed, to avoid duplication from autoprefixer when used. Inline comments in the preflight.css source code indicate which of these have been adjusted and note the original existing prefix.
  4. system-ui fonts have been removed completely from font-family properties in exchange for either websafe fonts (e.g. Courier New for monospace elements), or removed completely (in the case of the original preflight's font-family on :root).

Removing System UI Fonts

system-ui fonts can be problematic as they not only depend on the OS version, but on the language settings of the OS as well. These have been removed as it's felt they're too unpredictable to be left in as a preflight, and better left for a dev to intentionally specify them.

Installation

#pnpm
pnpm add css-preflight

#npm
npm install css-preflight

Usage

The exports are broken down into 4 main CSS files. Completely unprocessed so it's up to the dev to pass them through optimizations like Autoprefixer and minification.

Simply import these into the root layout file (like Layout.astro for example). They should be imported first before any other CSS imports.

Possible Imports

import 'css-preflight'; // styles/preflight.css
import 'css-preflight/preflight'; // ALIAS: styles/preflight.css

import 'css-preflight/enhancements'; // styles/enhancements.css
import 'css-preflight/smooth-scroll'; // styles/smooth-scroll.css
import 'css-preflight/rem-same-px'; // styles/rem-same-px.css

Typical Setup

import 'css-preflight';
import 'css-preflight/enhancements';

Preflight

Tailwind preflight (with adjustments mentioned previously). Can either do a bare css-preflight import, or use the more verbose option of css-preflight/preflight. Both are exactly the same.

Enhancements

These are small enhancements added to the main preflight:

  • Adds text-wrap: balance on h1-h6 and blockquote. Helps prevent hanging words on newlines.

Smooth Scroll

Enables smooth scrolling to anchor points (e.g. #about). Disabled for prefers-reduced-motion.

Rem Same Px

Sets rem equal to 1px at the root for easier design-dev handoff. This calculation is done using %, so the browser root font size will still affect fonts using rem for accessibility purposes.

License

The repo falls under MIT licensing, contained in the LICENSE.md file. Usage of the preflight.css file is also subject to Tailwind's licensing (MIT), which is included in the repo for reference.