Skip to content
This repository has been archived by the owner on Dec 16, 2023. It is now read-only.

neoncitylights/typed-css-utils

Repository files navigation

Typed CSS utilities

License: MIT GitHub deployments Node.js workflow NPM package

Important

This package still exists, but has moved to the neoncitylights/types monorepo.

This library provides a set of utilities extending the csstype package to help you write typed CSS in TypeScript.

Currently, there's basic support for the following W3C standards:

Install

npm install @neoncitylights/typed-css-utils

Documentation

Auto-generated API documentation is available.

API reference

Note: The public API below is an excerpt and shows the main symbols that a developer is likely to use.

Usage

Using TypeScript, you can receive type intelliSense, which provides autocomplete suggestions for:

  • CSS property names and values (through csstype)
  • Media feature names (e.g prefers-color-scheme, aspect-ratio)
import { matchMediaFeature, cssSupports } from '@neoncitylights/typed-css-utils';

// equivalent to window.matchMedia('(prefers-color-scheme: dark)');
const userPrefersDark: MediaQueryList = matchMediaFeature('prefers-color-scheme', 'dark');

// TypeScript support, which provides strongly typed CSS property
// names and values using the `csstype` package
const supportsGrid: boolean = cssSupports('display', 'grid');
const supportsFlex: boolean = cssSupports('display', 'flex');

License

This library is licensed under the MIT License.

About

Improved TypeScript support for CSS and relevant APIs, currently including CSS Conditionals L3 and CSS Media Queries L5.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published