Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/watfiree/mq

Util for media queries.
https://github.com/watfiree/mq

css javascript mobile-development mobile-first nextjs react responsive responsive-design styled-components typescript

Last synced: about 1 month ago
JSON representation

Util for media queries.

Awesome Lists containing this project

README

        

# mq

Create easily media queries when styling in any CSS-in-JS library.

## Installation

Install `mq` with npm or yarn

```bash
npm install @watfiree/mq
yarn add @watfiree/mq
```

## Usage/Examples

### With default config

```typescript
import styled from "styled-components";
import { mq } from "@watfiree/mq";

const ModalWrapper = styled.div`
background: black;
color: white;

${mq.from("xs")} {
background: grey;
color: darkgrey;
}

${mq.between("sm", "xl")} {
background: white;
color: black;
}
`;
```

### With your custom config

```typescript
import styled from "styled-components";
import { createMqEntity } from "@watfiree/mq";

type myNewBreakponts = "wd" | "ws"; // can be also enum

const mq = createMqEntity({ wd: "2000px", ws: "1200px" });

const ModalWrapper = styled.div`
background: black;
color: white;

${mq.from("wd")} {
background: grey;
color: darkgrey;
}

${mq.between("ws", "wd")} {
background: white;
color: black;
}
`;
```