0.2.0 • Published 1 year ago

@neoncitylights/typed-css-utils v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Typed CSS utils

License: MIT GitHub deployments Node.js workflow NPM package

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

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.