# postcss-media-fn

> Use `media()` to assign responsive values

Latest version **3.0.0** (published 2017-05-30) · CC0-1.0 license · 0 weekly downloads

## Install

```sh
npm install postcss-media-fn
pnpm add postcss-media-fn
yarn add postcss-media-fn
bun add postcss-media-fn
```

## 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 | 3.0.0 |
| Published | 2017-05-30 |
| First published | 2017-01-03 |
| Weekly downloads | 0 |
| License | CC0-1.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.0.0 |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+6 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 15 |
| Author | Jonathan Neal |
| Maintainers | jonathantneal |
| Keywords | postcss, css, postcss-plugin, media, function, method, responsive, query, custom, multiple, values |

## Links

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

## Dependencies (2)

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

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 3.0.0 (latest) — 2017-05-30
- 2.0.0 — 2017-01-08
- 1.0.0 — 2017-01-03

## README

# Media() [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][postcss]

[![NPM Version][npm-img]][npm-url]
[![Build Status][cli-img]][cli-url]
[![Gitter Chat][git-image]][git-url]

[Media()] lets you use the `media()` function to assign responsive values to a declaration, following the [CSS Media Expressions] specification.

```css
/* before */

h1 {
  font-size: media(
    16px,
    (min-width:  600px) 20px,
    (min-width: 1000px) 40px,
    (min-width: 1400px) 60px
  );
}


/* after */

h1 {
  font-size: 16px;
}

@media (min-width: 600px) {
  h1 {
    font-size: 20px;
  }
}

@media (min-width: 1000px) {
  h1 {
    font-size: 40px;
  }
}

@media (min-width: 1400px) {
  h1 {
    font-size: 60px;
  }
}
```

## Usage

Add [Media()] to your build tool:

```bash
npm install postcss-media-fn --save-dev
```

#### Node

```js
require('postcss-media-fn').process(YOUR_CSS, { /* options */ });
```

#### PostCSS

Add [PostCSS] to your build tool:

```bash
npm install postcss --save-dev
```

Load [Media()] as a PostCSS plugin:

```js
postcss([
  require('postcss-media-fn')({ /* options */ })
]).process(YOUR_CSS, /* options */);
```

#### Gulp

Add [Gulp PostCSS] to your build tool:

```bash
npm install gulp-postcss --save-dev
```

Enable [Media()] within your Gulpfile:

```js
var postcss = require('gulp-postcss');

gulp.task('css', function () {
  return gulp.src('./src/*.css').pipe(
    postcss([
      require('postcss-media-fn')({ /* options */ })
    ])
  ).pipe(
    gulp.dest('.')
  );
});
```

#### Grunt

Add [Grunt PostCSS] to your build tool:

```bash
npm install grunt-postcss --save-dev
```

Enable [Media()] within your Gruntfile:

```js
grunt.loadNpmTasks('grunt-postcss');

grunt.initConfig({
  postcss: {
    options: {
      use: [
        require('postcss-media-fn')({ /* options */ })
      ]
    },
    dist: {
      src: '*.css'
    }
  }
});
```

[npm-url]: https://www.npmjs.com/package/postcss-media-fn
[npm-img]: https://img.shields.io/npm/v/postcss-media-fn.svg
[cli-url]: https://travis-ci.org/jonathantneal/postcss-media-fn
[cli-img]: https://img.shields.io/travis/jonathantneal/postcss-media-fn.svg
[git-url]: https://gitter.im/postcss/postcss
[git-image]: https://img.shields.io/badge/chat-gitter-blue.svg

[Media()]: https://github.com/jonathantneal/postcss-media-fn
[CSS Media Expressions]: https://jonathantneal.github.io/media-expressions-spec/
[PostCSS]: https://github.com/postcss/postcss
[Gulp PostCSS]: https://github.com/postcss/gulp-postcss
[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss

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