# css-typed-om

> A fully tested polyfill for the [CSS Typed OM Level 1 Specification](https://drafts.css-houdini.org/css-typed-om-1/).

Latest version **1.0.0** (published 2026-08-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install css-typed-om
pnpm add css-typed-om
yarn add css-typed-om
bun add css-typed-om
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2026-08-19 |
| First published | 2018-03-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 846.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Bramus Van Damme |
| Maintainers | jonathantneal, alaguna, romainmenke, bramus |
| Keywords | css, css-typed-om, typed-om, polyfill, houdini, style-property-map, attribute-style-map |

## Links

- npm: https://www.npmjs.com/package/css-typed-om
- Repository: https://github.com/bramus/css-typed-om-polyfill
- Homepage: https://github.com/bramus/css-typed-om-polyfill#readme
- Issues: https://github.com/bramus/css-typed-om-polyfill/issues
- npm.io page: https://npm.io/package/css-typed-om

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2026-08-19
- 0.4.0 — 2018-05-11
- 0.3.0 — 2018-04-18
- 0.2.0 — 2018-04-04
- 0.1.0 — 2018-04-02
- 0.0.0 — 2018-03-29

## README

# CSS Typed OM Polyfill

This polyfill brings the [CSS Typed OM Level 1 Specification](https://drafts.css-houdini.org/css-typed-om-1/) to browsers that do not yet support it, allowing you to interact with CSS values as typed JavaScript objects rather than strings.

This project is fully tested using the official [Web Platform Tests (WPT)](https://github.com/web-platform-tests/wpt).

<!-- WPT_STATUS_START -->
- WPT Commit: [`fbc1b90e2`](https://github.com/web-platform-tests/wpt/tree/fbc1b90e2) (*2026-08-19T10:43:39Z*)
- PASS: 12476 / 13134
- FAIL: 658 / 13134
<!-- WPT_STATUS_END -->

## Features

- **Specification-Compliant**: Implementation matches the CSS Typed OM Level 1 spec.
- **Automatic Polyfilling**: Automatically patches `window.CSS`, `Element.prototype.computedStyleMap`, `HTMLElement.prototype.attributeStyleMap`, and other relevant interfaces if running in a browser.
- **Typed Values**: Supports `CSSUnitValue`, `CSSMathValue`, `CSSTransformValue`, `CSSColorValue`, and more.
- **Fully Typed**: Written in TypeScript with standard types exported.
- **ESM & IIFE Support**: Built for modern environments and direct browser script usage.
- **Fully WPT Tested**: This project is fully tested using the official [Web Platform Tests (WPT)](https://github.com/web-platform-tests/wpt).

## Installation

```bash
npm install css-typed-om
```

## Usage

### 1. As a Polyfill

Simply import the package to automatically install the polyfill on the global scope:

```javascript
import 'css-typed-om';

// Now you can use the typed OM API
const element = document.querySelector('.my-element');
const width = element.computedStyleMap().get('width');

console.log(width.value); // e.g., 100
console.log(width.unit);  // e.g., 'px'

// Setting styles
element.attributeStyleMap.set('opacity', CSS.number(0.5));
element.attributeStyleMap.set('margin-top', CSS.px(20));
```

### 2. As a Module (Explicit Imports)

If you prefer to use the classes directly without relying on global patching (or for testing/Node environments):

```javascript
import { CSSUnitValue, CSSKeywordValue } from 'css-typed-om';

const width = new CSSUnitValue(100, 'px');
const display = new CSSKeywordValue('block');
```

## Development

### Installation

To install dependencies for development:

```bash
npm install
```

### Building

To build the project (ESM, IIFE, and Types):

```bash
npm run build
```

### Testing

To run all tests (unit and Web Platform Tests):

```bash
npm run test
```

Or you can run them individually:

1.  **Unit Tests**: Fast tests using Vitest.
    ```bash
    npm run test:unit
    ```

2.  **Web Platform Tests (WPT)**: Runs the official WPT suite for CSS Typed OM.
    ```bash
    # Run WPT tests (requires Python and Firefox)
    npm run test:wpt
    
    # Run WPT tests locally for debugging
    npm run test:wpt:local
    
    # Update WPT to latest version
    npm run test:wpt:update
    ```

## Acknowledgements

The package name `css-typed-om` was kindly handed over by Jonathan Neal who authored the (now archived) https://github.com/csstools/css-typed-om project.

## License

MIT

## Disclaimer

This project is mostly AI-generated using [Google Antigravity](https://antigravity.google/), based on the spec and WPT.

---
_Source: https://npm.io/package/css-typed-om · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
