npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@type-dom/css-type

v0.2.0

Published

基于TypeScript的CSS类型定义库,提供类型安全的CSS属性、值和工具类型,帮助开发者在TypeScript项目中编写更可靠的CSS代码。

Readme

css-type

基于TypeScript的CSS类型定义库,提供类型安全的CSS属性、值和工具类型,帮助开发者在TypeScript项目中编写更可靠的CSS代码。


特性

  • 完整的CSS属性类型定义(如color, flex, transition等)
  • 常用CSS值类型集合(如颜色值、长度单位、定位值等)
  • 基于CSS规范的类型推导
  • 支持自定义类型扩展
  • 兼容现代CSS特性(如CSS Grid, Flexbox等)

安装

bash npm install @type-dom/css-type --save
或
yarn add @type-dom/css-type

快速上手

基础用法

typescript
import type { CSSProperties } from '@type-dom/css-type';
const componentStyle: CSSProperties = { display: 'flex', // ✅ 合法值
flexDirection: 'row', // ✅ 合法值
invalidProp: 'error', // ❌ 类型报错
padding: '1rem 2rem', // ✅ 合法值
borderRadius: '50%', // ✅ 合法值 };

扩展类型定义

typescript
import type { CSSProperties, CSSLength } from '@type-dom/css-type';
type CustomCSSProperties = CSSProperties & { '--custom-var': CSSLength; // 声明自定义CSS变量类型 };
const extendedStyle: CustomCSSProperties = { '--custom-padding': '1.5rem', // ✅ 合法值 };

核心类型

CSSProperties

包含所有标准CSS属性的类型定义,例如:

| 属性名 | 允许值类型 | |------------------|-------------------------------------------------------| | color | CSSColor | | display | CSSDisplay | | padding | CSSLength | CSSPercentage | | transition | CSSTransitionProperty | | gap | CSSLength |

基础值类型

  • CSSColor:支持#RRGGBBrgb()hsl()等格式
  • CSSLength:支持pxremem%等单位
  • CSSPositiontopbottomleftright等定位值
  • CSSDisplay:所有合法display属性值集合

兼容性

  • 支持所有现代浏览器
  • 需要 TypeScript 4.0+ 版本
  • 兼容主流CSS预处理器(Sass/Less)

贡献指南

  1. Fork仓库并创建新分支
  2. 修改类型定义时请参考最新CSS规范
  3. 提交PR前运行测试:npm run test
  4. 遵循贡献规范

许可证

MIT License © TypeDom Team