@johanneslumpe/css-types
v0.4.0
Published
TypeScript CSS types and value helpers generated from MDN data
Downloads
3
Readme
css-types
This library provides TypeScript types for CSS properties. It uses data provided by MDN to generate types. This project is similar to https://github.com/frenic/csstype, but differs in some key points:
- Allow typing of dynamic user input for lengths and other custom inputs
- Generate pre-combined types where possible, e.g. the
display
property - Usage of tuples to express non-combineable types
- Exported types aren't exhaustive, only standard property types are generated
It has mainly been designed to generate types which could be consumed by https://github.com/johanneslumpe/styled-props which can natively work with the generated tuple types. Maybe others will find this helpful as well.
The type generation process itself works, but doesn't yet support all CSS features. E.g. functions are aliased to string
, instead of auto-generated helper functions which return branded types.
All properties are suffixed with Property
and combined types are suffixed with Combined
, e.g. DisplayProperty
and DisplayPropertyCombined
.
Get it
npm i @johanneslumpe/css-types
Use it
TODO
Documentation
Typedocs can be found in the docs folder