neoncitylights / typed-css-utils

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

Home Page:https://neoncitylights.github.io/typed-css-utils/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

https://neoncitylights.github.io/typed-css-utils/

License:MIT License


Languages

Language:TypeScript 83.1%Language:Dockerfile 8.6%Language:JavaScript 8.3%