# css-shorthand-properties

> A simple list of CSS shorthand properties and which longhand properties they expand to

Latest version **1.1.2** (published 2024-09-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install css-shorthand-properties
pnpm add css-shorthand-properties
yarn add css-shorthand-properties
bun add css-shorthand-properties
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2024-09-27 |
| First published | 2014-10-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 10.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 23 |
| Author | Gilmore Davidson |
| Maintainers | gilmoreorless |
| Keywords | css, shorthand, short, list |

## Links

- npm: https://www.npmjs.com/package/css-shorthand-properties
- Repository: https://github.com/gilmoreorless/css-shorthand-properties
- Issues: https://github.com/gilmoreorless/css-shorthand-properties/issues
- npm.io page: https://npm.io/package/css-shorthand-properties

## 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.1.2 (latest) — 2024-09-27
- 1.1.1 — 2018-07-17
- 1.1.0 — 2017-11-11
- 1.0.0 — 2014-11-24
- 0.1.0 — 2014-10-23

## README

# CSS Shorthand Properties

A simple way to list all [shorthand](https://www.w3.org/TR/CSS2/about.html#shorthand) CSS properties and which properties they expand to.

I tried to search for an existing simple list but couldn't find one, so I trawled through the various [W3C CSS specs](https://www.w3.org/Style/CSS/current-work) and collated the data.

Only specs that are Candidate Recommendations or better are counted, with the exception of some Working Drafts that have a lot of traction in browser implementations. So far the WD specs included here are Animation and Transitions.

## Usage

Available on npm as `css-shorthand-properties`, or in the browser as a global called `cssShorthandProps`

### Properties

#### shorthandProperties

The core data as a simple JS object. Each key is a CSS shorthand property. Each value is a compacted list of CSS properties that the shorthand expands to.

There is a convenience method (listed below) that means you shouldn’t need to access this list directly, but it’s available for other use cases.


### Methods

#### isShorthand

* Returns a boolean indicating if a CSS property is a shorthand.
* **Parameters**:
    * `property` _(String)_ Shorthand property to expand.
* **Returns**: _Boolean_

```js
cssShorthandProps.isShorthand('border');  // true
cssShorthandProps.isShorthand('display');  // false
```

#### expand

* Takes a CSS shorthand property and returns a list of longhand properties.
* **Parameters**:
    * `property` _(String)_ Shorthand property to expand.
    * `recurse` _(Boolean – optional, default `false`)_ If true, each longhand property will also be run through `expand()`. This is only useful for the `border` property.
* **Returns**: _Array_ with a list of longhand properties that the given property expands to. If the property is not a shorthand, the array contains only the original property.

```js
// Standard usage
cssShorthandProps.expand('list-style');
// ['list-style-type', 'list-style-position', 'list-style-image']

// Non-shorthand properties return themselves in an array
cssShorthandProps.expand('color');
// ['color']

// Using 'border' in normal mode...
cssShorthandProps.expand('border');
// ['border-width', 'border-style', 'border-color']

// ...but the border properties are also shorthands
cssShorthandProps.expand('border-width');
// ['border-top-width', 'border-right-width', 'border-bottom-width', 'border-left-width']

// Using 'border' with recursion returns an array of arrays
cssShorthandProps.expand('border', true);
/*
[
  ['border-top-width', 'border-right-width', 'border-bottom-width', 'border-left-width'],
  ['border-top-style', 'border-right-style', 'border-bottom-style', 'border-left-style'],
  ['border-top-color', 'border-right-color', 'border-bottom-color', 'border-left-color']
]
*/
```

## Licence

MIT: [https://gilmoreorless.mit-license.org/]()

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