# postcss-clamp

> PostCSS plugin to transform clamp() to combination of min/max

Latest version **4.1.0** (published 2022-03-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install postcss-clamp
pnpm add postcss-clamp
yarn add postcss-clamp
bun add postcss-clamp
```

## Health

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

Positive: has types package; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.1.0 |
| Published | 2022-03-11 |
| First published | 2020-05-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/postcss-clamp) |
| Module format | CommonJS |
| Node | >=7.6.0 |
| Dependencies | 1 |
| Unpacked size | 16.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 30 |
| Author | Ivan Menshykov |
| Maintainers | polemius |
| Keywords | postcss, css, postcss-plugin, clamp, min, max |

## Links

- npm: https://www.npmjs.com/package/postcss-clamp
- Repository: https://github.com/polemius/postcss-clamp
- Homepage: https://github.com/polemius/postcss-clamp#readme
- Issues: https://github.com/polemius/postcss-clamp/issues
- npm.io page: https://npm.io/package/postcss-clamp

## Dependencies (1)

- [postcss-value-parser](https://npm.io/package/postcss-value-parser.md) ^4.2.0

## 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

- 4.1.0 (latest) — 2022-03-11
- 4.0.0 — 2022-02-16
- 3.0.0 — 2022-01-06
- 2.0.0 — 2021-01-12
- 1.1.0 — 2020-05-09
- 1.0.0 — 2020-05-05
- 0.2.0 — 2020-05-03
- 0.1.0 — 2020-05-03

## README

# PostCSS Clamp
[![Build Status][ci-img]][ci] [![codecov.io][cov-img]][cov]

[PostCSS] plugin to transform `clamp()` to combination of `min/max`.

[PostCSS]:    https://github.com/postcss/postcss
[ci-img]:     https://travis-ci.com/polemius/postcss-clamp.svg?branch=master
[ci]:         https://travis-ci.com/polemius/postcss-clamp
[cov-img]: https://codecov.io/github/polemius/postcss-clamp/coverage.svg?branch=master
[cov]:        https://codecov.io/github/polemius/postcss-clamp?branch=master

This plugin transform this css:

```css
.foo {
  width: clamp(10px, 4em, 80px);
}
```

into this:

```css
.foo {
  width: max(10px, min(4em, 80px));
}
```

Or with enabled options `precalculate`:

```css
.foo {
  width: clamp(10em, 4px, 10px);
}

/* becomes */

.foo {
  width: max(10em, 14px);
}
```

[!['Can I use' table](https://caniuse.bitsofco.de/image/css-math-functions.png)](https://caniuse.com/#feat=css-math-functions)

## Instalation

```bash
$ npm install postcss postcss-clamp --save-dev
or
$ yarn add --dev postcss postcss-clamp
```

## Usage

Use [PostCSS Clamp] as a [PostCSS] plugin:

```js
const postcss = require('postcss');
const postcssClamp = require('postcss-clamp');

postcss([
  postcssClamp(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);
```

[PostCSS Clamp] runs in all Node environments, with special instructions for:

| [Node](INSTALL.md#node) | [PostCSS CLI](INSTALL.md#postcss-cli) | [Webpack](INSTALL.md#webpack) | [Create React App](INSTALL.md#create-react-app) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) |
| --- | --- | --- | --- | --- | --- |

See [PostCSS] docs for examples for your environment.

## Options

### precalculate

The `precalculate` option determines whether values with the same unit
should be precalculated. By default, these are not precalculation.

```js
postcssColorHexAlpha({
  precalculate: true
});
```

The second and third value has the same unit (`px`):

```css
.foo {
  width: clamp(10em, 4px, 10px);
}

/* becomes */

.foo {
  width: max(10em, 14px);
}
```

Here all values have the same unit:

```css
.foo {
  width: clamp(10px, 4px, 10px);
}

/* becomes */

.foo {
  width: 24px;
}
```

## LICENSE

See [LICENSE](LICENSE)

[PostCSS]: https://github.com/postcss/postcss
[PostCSS Clamp]: https://github.com/polemius/postcss-clamp

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