Gathering detailed insights and metrics for @roseys/csstype
Gathering detailed insights and metrics for @roseys/csstype
Gathering detailed insights and metrics for @roseys/csstype
Gathering detailed insights and metrics for @roseys/csstype
Strict TypeScript and Flow types for style based on MDN data
npm install @roseys/csstype
Typescript
Module System
Node Version
NPM Version
78.8
Supply Chain
98.8
Quality
75.4
Maintenance
100
Vulnerability
100
License
TypeScript (98%)
JavaScript (2%)
Total Downloads
9,269
Last Day
1
Last Week
8
Last Month
36
Last Year
6,598
MIT License
1,770 Stars
359 Commits
76 Forks
8 Watchers
8 Branches
12 Contributors
Updated on Jul 02, 2025
Latest Version
2.6.9-beta.0
Package Id
@roseys/csstype@2.6.9-beta.0
Unpacked Size
1.87 MB
Size
279.87 kB
File Count
647
NPM Version
6.4.1
Node Version
10.11.0
Cumulative downloads
Total Downloads
Last Day
0%
1
Compared to previous day
Last Week
100%
8
Compared to previous week
Last Month
-93.8%
36
Compared to previous month
Last Year
1,722.7%
6,598
Compared to previous year
TypeScript and Flow definitions for CSS, generated by data from MDN. It provides autocompletion and type checking for CSS properties and values.
1import * as CSS from 'csstype'; 2 3const style: CSS.Properties = { 4 colour: 'white', // Type error on property 5 textAlign: 'middle', // Type error on value 6};
1$ npm install csstype 2$ # or 3$ yarn add csstype
Properties are categorized in different uses and in several technical variations to provide typings that suits as many as possible.
All interfaces has one optional generic argument to define length. It defaults to string | 0
because 0
is the only unitless length. You can specify this, e.g. string | number
, for platforms and libraries that accepts any numeric value as length with a specific unit.
Default | Hyphen | Fallback | HyphenFallback | |
---|---|---|---|---|
All | Properties | PropertiesHyphen | PropertiesFallback | PropertiesHyphenFallback |
Standard | StandardProperties | StandardPropertiesHyphen | StandardPropertiesFallback | StandardPropertiesHyphenFallback |
Vendor | VendorProperties | VendorPropertiesHyphen | VendorPropertiesFallback | VendorPropertiesHyphenFallback |
Obsolete | ObsoleteProperties | ObsoletePropertiesHyphen | ObsoletePropertiesFallback | ObsoletePropertiesHyphenFallback |
Svg | SvgProperties | SvgPropertiesHyphen | SvgPropertiesFallback | SvgPropertiesHyphenFallback |
Categories:
Standard
, Vendor
, Obsolete
and Svg
Standard
- Current properties and extends subcategories StandardLonghand
and StandardShorthand
(e.g. StandardShorthandProperties
)Vendor
- Vendor prefixed properties and extends subcategories VendorLonghand
and VendorShorthand
(e.g. VendorShorthandProperties
)Obsolete
- Removed or deprecated propertiesSvg
- SVG-specific propertiesVariations:
Hyphen
- CSS (kebab) cased property namesFallback
- Also accepts array of values e.g. string | string[]
At-rule interfaces with descriptors.
Default | Hyphen | Fallback | HyphenFallback | |
---|---|---|---|---|
@counter-style | CounterStyle | CounterStyleHyphen | CounterStyleFallback | CounterStyleHyphenFallback |
@font-face | FontFace | FontFaceHyphen | FontFaceFallback | FontFaceHyphenFallback |
@page | Page | PageHyphen | PageFallback | PageHyphenFallback |
@viewport | Viewport | ViewportHyphen | ViewportFallback | ViewportHyphenFallback |
String literals of pseudo classes and pseudo elements
Pseudos
Extends:
AdvancedPseudos
Function-like pseudos e.g. :not(:first-child)
. The string literal contains the value excluding the parenthesis: :not
. These are separated because they require an argument that results in infinite number of variations.
SimplePseudos
Plain pseudos e.g. :hover
that can only be one variation.
Length defaults to string | 0
. But it's possible to override it using generics.
1import * as CSS from 'csstype'; 2 3const style: CSS.Properties<string | number> = { 4 padding: 10, 5 margin: '1rem', 6};
In some cases, like for CSS-in-JS libraries, an array of values is a way to provide fallback values in CSS. Using CSS.PropertiesFallback
instead of CSS.Properties
will add the possibility to use any property value as an array of values.
1import * as CSS from 'csstype'; 2 3const style: CSS.PropertiesFallback = { 4 display: ['-webkit-flex', 'flex'], 5 color: 'white', 6};
There's even string literals for pseudo selectors and elements.
1import * as CSS from 'csstype'; 2 3const pseudos: { [P in CSS.SimplePseudos]?: CSS.Properties } = { 4 ':hover': { 5 display: 'flex', 6 }, 7};
Hyphen cased (kebab cased) properties are provided in CSS.PropertiesHyphen
and CSS.PropertiesHyphenFallback
. It's not not added by default in CSS.Properties
. To allow both of them, you can simply extend with CSS.PropertiesHyphen
or/and CSS.PropertiesHyphenFallback
.
1import * as CSS from 'csstype'; 2 3interface Style extends CSS.Properties, CSS.PropertiesHyphen {} 4 5const style: Style = { 6 'flex-grow': 1, 7 'flex-shrink': 0, 8 'font-weight': 'normal', 9 backgroundColor: 'white', 10};
The goal is to have as perfect types as possible and we're trying to do our best. But with CSS Custom Properties, the CSS specification changing frequently and vendors implementing their own specifications with new releases sometimes causes type errors even if it should work. Here's some steps you could take to get it fixed:
If you're using CSS Custom Properties you can step directly to step 3.
First of all, make sure you're doing it right. A type error could also indicate that you're not :wink:
Type 'string' is not assignable to...
errorsHave a look in issues to see if an issue already has been filed. If not, create a new one. To help us out, please refer to any information you have found.
Fix the issue locally with TypeScript (Flow further down):
The recommended way is to use module augmentation. Here's a few examples:
1// My css.d.ts file 2import * as CSS from 'csstype'; 3 4declare module 'csstype' { 5 interface Properties { 6 // Add a missing property 7 WebkitRocketLauncher?: string; 8 9 // Add a CSS Custom Property 10 '--theme-color'?: 'black' | 'white'; 11 12 // ...or allow any other property 13 [index: string]: any; 14 } 15}
The alternative way is to use type assertion. Here's a few examples:
1const style: CSS.Properties = { 2 // Add a missing property 3 ['WebkitRocketLauncher' as any]: 'launching', 4 5 // Add a CSS Custom Property 6 ['--theme-color' as any]: 'black', 7};
Fix the issue locally with Flow:
Use type assertion. Here's a few examples:
1const style: $Exact<CSS.Properties<*>> = { 2 // Add a missing property 3 [('WebkitRocketLauncher': any)]: 'launching', 4 5 // Add a CSS Custom Property 6 [('--theme-color': any)]: 'black', 7};
The casing of CSS vendor properties are changed matching the casing of prefixes in Javascript. So all of them are capitalized except for ms
.
msOverflowStyle
is still msOverflowStyle
mozAppearance
is now MozAppearance
webkitOverflowScrolling
is now WebkitOverflowScrolling
More info: https://www.andismith.com/blogs/2012/02/modernizr-prefixed/
Never modify index.d.ts
and index.js.flow
directly. They are generated automatically and committed so that we can easily follow any change it results in. Therefor it's important that you run $ git config merge.ours.driver true
after you've forked and cloned. That setting prevents merge conflicts when doing rebase.
yarn build
Generates typings and type checks themyarn watch
Runs build on each saveyarn test
Runs the testsyarn lazy
Type checks, lints and formats everythingNo vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 3/25 approved changesets -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
11 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More