# media-engine

> Media query calculator

Latest version **2.0.0** (published 2026-08-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install media-engine
pnpm add media-engine
yarn add media-engine
bun add media-engine
```

## Health

**Score 60/100 (C)** — status: active.

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

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2026-08-16 |
| First published | 2018-03-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Diego Muracciole |
| Maintainers | diegomura |

## Links

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

## Recent versions

- 2.0.0 (latest) — 2026-08-16
- 1.0.3 — 2018-03-08
- 1.0.2 — 2018-03-08
- 1.0.1 — 2018-03-02
- 1.0.0 — 2018-03-01
- 0.0.1 — 2018-03-01

## README

# media-engine
> Media queries engine written in pure JS!

[![npm](https://img.shields.io/npm/v/media-engine.svg)](https://npm.im/media-engine)
[![Travis](https://img.shields.io/travis/diegomura/media-engine.svg)](https://travis-ci.org/diegomura/media-engine)
[![license](https://img.shields.io/npm/l/media-engine.svg)](./LICENSE)

## Install
```sh
npm install media-engine --save
# or
yarn add media-engine
```

## API
`min-height`
```js
matchMedia(
  {
    '@media min-height: 700': {
      color: 'green',
    },
  },
  { height: 800 }
);
// { color: 'green' }

matchMedia(
  {
    '@media min-height: 700': {
      color: 'green',
    },
  },
  { height: 100 }
);
// { }
```

`max-height`
```js
matchMedia(
  {
    '@media max-height: 700': {
      color: 'green',
    },
  },
  { height: 100 }
);
// { color: 'green' }

matchMedia(
  {
    '@media max-height: 700': {
      color: 'green',
    },
  },
  { height: 800 }
);
// { }
```

`min-width`
```js
matchMedia(
  {
    '@media min-width: 700': {
      color: 'green',
    },
  },
  { width: 800 }
);
// { color: 'green' }

matchMedia(
  {
    '@media min-width: 700': {
      color: 'green',
    },
  },
  { width: 100 }
);
// { }
```

`max-width`
```js
matchMedia(
  {
    '@media max-width: 700': {
      color: 'green',
    },
  },
  { width: 100 }
);
// { color: 'green' }

matchMedia(
  {
    '@media max-width: 700': {
      color: 'green',
    },
  },
  { width: 800 }
);
// { }
```

`orientation`
```js
matchMedia(
  {
    '@media orientation: landscape': {
      color: 'green',
    },
  },
  { orientation: 'landscape' }
);
// { color: 'green' }

matchMedia(
  {
    '@media orientation: landscape': {
      color: 'green',
    },
  },
  { orientation: 'portrait' }
);
// { }
```

`and operator`
```js
matchMedia(
  {
    '@media (min-width: 700) and (orientation: landscape)': {
      color: 'green',
    },
  },
  { width: 800, orientation: 'landscape' }
);
// { color: 'green' }
```

`or operator`
```js
matchMedia(
  {
    '@media (min-width: 700), (orientation: landscape)': {
      color: 'green',
    },
  },
  { orientation: 'landscape' }
);
// { color: 'green' }
```

`multiple queries`
```js
matchMedia(
  {
    '@media orientation: landscape': {
      color: 'green',
    },
    '@media min-width: 700': {
      background: 'red',
    }
  },
  { orientation: 'landscape', width: 800 }
);
// { color: 'green', background: 'red' }
```

## License
MIT © [Diego Muracciole](http://github.com/diegomura)

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