# @o/css

> Turns objects into nice CSS styles. Has a few helpers:

Latest version **2.8.23** (published 2021-03-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install @o/css
pnpm add @o/css
yarn add @o/css
bun add @o/css
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.8.23 |
| Published | 2021-03-18 |
| First published | 2019-03-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 426.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Motion |
| Maintainers | nwienert |

## Links

- npm: https://www.npmjs.com/package/@o/css
- npm.io page: https://npm.io/package/@o/css

## Recent versions

- 2.8.23 (latest) — 2021-03-18
- 2.8.22 — 2021-03-18
- 2.8.21 — 2021-03-18
- 2.8.20 — 2021-03-18
- 2.8.19 — 2021-03-17
- 2.8.18 — 2021-03-17
- 2.8.17 — 2021-03-17
- 2.8.16 — 2021-03-17
- 2.8.15 — 2021-03-17
- 2.8.11 — 2021-03-17
- 2.7.21 — 2021-03-13
- 2.7.20 — 2021-03-13
- 2.7.19 — 2021-03-13
- 2.7.18 — 2021-03-13
- 2.7.17 — 2021-03-13
- … 19 more at https://npm.io/package/@o/css/versions

## README

## @o/css

Turns objects into nice CSS styles. Has a few helpers:

* Arrays to strings:

```js
{
  border: [1, 'solid', '#eee'], // 1px solid #eee
  border: [1, '#eee'], // defaults (solid)
  color: [0, 0, 0, 0.5], // rgba(0,0,0,0.5)
}
```

* Transform objects:

```js
{
  transform: { x: 0, y: 10, z: 0, rotate: '100deg' }
}
```

* Color objects:

```js
{
  background: [0, 255, 0, 0.5] // rgba(0, 255, 0, 0.5)
}
```

* Converts css-able functions/objects:

```js
{
  background: chroma('#fff') // will call .css() automatically
}
```

* Recurses into media queries + & selectors

```js
{
  '@media screen': { ... }
}
```

```js
{
  '& child': { ... }
}
```

* Extra border shorthands

```js
{
  borderLeftRadius: ['borderTopLeftRadius', 'borderBottomLeftRadius'],
  borderRightRadius: ['borderTopRightRadius', 'borderBottomRightRadius'],
  borderBottomRadius: ['borderBottomLeftRadius', 'borderBottomRightRadius'],
  borderTopRadius: ['borderTopRightRadius', 'borderTopLeftRadius'],
}
```

* Position shorthand

```js
{
  position: [0, 'auto', 20, '50%'],
  /*
    position: absolute;
    top: 0px;
    right: auto;
    bottom: 20px;
    left: 50%;
  */
  position: ['fixed', 0, 'auto'],
  /*
    position: fixed;
    top: 0px;
    right: auto;
  */
}
```

* Comma separations for multiple boxShadows and transitions:

```js
{
  boxShadow: [
    { x: 5, y: 5, blur: 2, spread: 5, color: [0, 0, 0, 0.1] },
    [0, 0, 10, [0, 0, 0, 0.2]],
  ]
}
```

* Object to value:

```js
{
  background: {
    color: 'green',
    image: 'url(image.jpg)',
    position: [0, 0],
    repeat: 'no-repeat'
  }
}
```

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