All Projects β†’ mg901 β†’ Styled Breakpoints

mg901 / Styled Breakpoints

Licence: mit
Simple and powerful tool for creating breakpoints in styled components and emotion. πŸ’…

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Styled Breakpoints

Filbert Js
A lightweight(~1kb) css-in-js framework
Stars: ✭ 167 (-60.98%)
Mutual labels:  styled-components, preact, css-in-js, emotion
Design System Utils
πŸ‘©β€πŸŽ¨ Access your design tokens with ease
Stars: ✭ 465 (+8.64%)
Mutual labels:  styled-components, preact, css-in-js, emotion
Goober
πŸ₯œ goober, a less than 1KB πŸŽ‰ css-in-js alternative with a familiar API
Stars: ✭ 2,317 (+441.36%)
Mutual labels:  styled-components, preact, css-in-js, emotion
React Next Boilerplate
πŸš€ A basis for reducing the configuration of your projects with nextJS, best development practices and popular libraries in the developer community.
Stars: ✭ 129 (-69.86%)
Mutual labels:  styled-components, css-in-js, emotion
mediocre-pictures
Helping you take mediocre pictures, hands-free. πŸ“·πŸ™†πŸ»πŸ™…πŸΎπŸ’πŸΌπŸ“Έ
Stars: ✭ 16 (-96.26%)
Mutual labels:  preact, styled-components, css-in-js
Xstyled
A utility-first CSS-in-JS framework built for React. πŸ’…πŸ‘©β€πŸŽ€βš‘οΈ
Stars: ✭ 1,835 (+328.74%)
Mutual labels:  styled-components, css-in-js, emotion
Horror
😱 React HTML elements with CSS-in-JS
Stars: ✭ 78 (-81.78%)
Mutual labels:  styled-components, css-in-js, emotion
Next Dark Mode
πŸŒ‘ Enable dark mode for Next.js apps
Stars: ✭ 133 (-68.93%)
Mutual labels:  styled-components, css-in-js, emotion
Twin.macro
πŸ¦Ήβ€β™‚οΈ Twin blends the magic of Tailwind with the flexibility of css-in-js (emotion, styled-components, stitches and goober) at build time.
Stars: ✭ 5,137 (+1100.23%)
Mutual labels:  styled-components, css-in-js, emotion
Styled Ppx
Typed styled components in Reason, OCaml and ReScript
Stars: ✭ 236 (-44.86%)
Mutual labels:  styled-components, css-in-js, emotion
Styled Components Vs Emotion
a short doc comparing the popular CSS-in-JS libraries styled-components and emotion
Stars: ✭ 204 (-52.34%)
Mutual labels:  styled-components, css-in-js, emotion
Styled Components Breakpoint
Utility function for using breakpoints with styled-components πŸ’….
Stars: ✭ 231 (-46.03%)
Mutual labels:  media, styled-components, breakpoint
Styled-Responsive-Media-Queries
Responsive Media Queries for Emotion styled or styled-components β€” Standard size from Chrome DevTools.
Stars: ✭ 33 (-92.29%)
Mutual labels:  styled-components, emotion, css-in-js
Css In React
🍭 CSS in React - Learn the best CSS in JS frameworks by example
Stars: ✭ 101 (-76.4%)
Mutual labels:  styled-components, css-in-js, emotion
Scoped Style
A tiny css in js library πŸš€
Stars: ✭ 129 (-69.86%)
Mutual labels:  styled-components, preact, css-in-js
Onno
Responsive style props for building themed design systems
Stars: ✭ 95 (-77.8%)
Mutual labels:  styled-components, css-in-js, emotion
tsstyled
A small, fast, and simple CSS-in-JS solution for React.
Stars: ✭ 52 (-87.85%)
Mutual labels:  styled-components, emotion, css-in-js
Styled Tools
Useful interpolated functions for CSS-in-JS
Stars: ✭ 761 (+77.8%)
Mutual labels:  styled-components, css-in-js, emotion
Styled System
β¬’ Style props for rapid UI development
Stars: ✭ 7,126 (+1564.95%)
Mutual labels:  styled-components, css-in-js, emotion
Grid
This package has moved and renamed
Stars: ✭ 2,079 (+385.75%)
Mutual labels:  styled-components, css-in-js, emotion


styled-breakpoints
GitHub Workflow Status coverage status npm bundle size npm downloads npm version

Simple and powerful tool for creating media queries with

styled-components     OR    emotion

Documentation

Examples

Getting Started

API

Examples

Mobile First

From smallest to largest

Edit mobile-first

Desktop First

From largest to smallest

Edit desktop first example

Hooks API

Styled Components

Hooks api (styled-components)

Emotion

Hooks api (Emotion)

Getting Started

Installation

npm install styled-breakpoints

# or

yarn add styled-breakpoints

Default breakpoints

{
  xs: '0px',
  sm: '576px',
  md: '768px',
  lg: '992px',
  xl: '1200px',
}
import { up, down, between, only } from 'styled-breakpoints';

const Component = styled.div`
  color: black;

  ${only('md')} {
    color: rebeccapurple;
  }
`;

Custom breakpoints

import { up, down, between, only } from 'styled-breakpoints';

const theme = {
  breakpoints: {
    sm: '576px',
    md: '768px',
    lg: '992px',
    xl: '1200px',
  },
};

const Component = styled.div`
  color: black;

  ${only('sm')} {
    color: rebeccapurple;
  }

  ${between('sm', 'md')} {
    color: hotpink;
  }

  ${down('lg')} {
    color: lightcoral;
  }

  ${up('xl')} {
    color: hotpink;
  }
`;

<ThemeProvider theme={theme}>
  <Component>This is cool!</Component>
</ThemeProvider>;

Object notation

When using object notation, make sure to explicitly pass props to breakpoint methods. Please see the example below using default configuration:

import { down, between } from 'styled-breakpoints';

const Component = styled('div')((props) => ({
  color: 'black',
  [down('md')(props)]: {
    color: 'lightcoral',
  },
  [between('sm', 'md')(props)]: {
    color: 'hotpink',
  },
}));

Hooks API

Styled Components

import { useBreakpoint } from 'styled-breakpoints/react-styled';

Emotion

import { useBreakpoint } from 'styled-breakpoints/react-emotion';


API

Core API is inspired by Bootstrap responsive breakpoints.

All incoming values are converted to em

For example, let's take default values of breakpoints.

up

/**
 *
 * @param {string} min-width
 * @param {string} [orientation]
 *
 * @return {string} media query
 */
up('md') => '@media (min-width: 768px) { ... }'

down

We occasionally use media queries that go in the other direction (the given screen size or smaller):

/**
 *
 * @param {string} max-width
 * @param {string} [orientation]
 *
 * @return {string} media query
 */
  down('md') => '@media (max-width: 991.98px) { ... }'

Note that since browsers do not currently support range context queries, we work around the limitations of min- and max- prefixes and viewports with fractional widths (which can occur under certain conditions on high-dpi devices, for instance) by using values with higher precision for these comparisons.


Similarly, media queries may span multiple breakpoint widths:

between

/**
 *
 * @param {string} min-width
 * @param {string} max-width
 * @param {string} [orientation]
 *
 * @return {string} media query
 */
between('md', 'lg') => '@media (min-width: 768px) and (max-width: 1199.98px) { ... }'

only

/**
 *
 * @param {string} min-width
 * @param {string} [orientation]
 *
 * @return {string} media query
 */
only('md') => '@media (min-width: 768px) and (max-width: 991.98px) { ... }'

useBreakpoint

/**
 * @param {function} up | down | between | only
 *
 * @return {(boolean|null)} `true` if currently matching the given query,
 *                          `false` if not, and `null` if unknown (such as
 *                          during server-side rendering)
 */
useBreakpoint(up('md')) => boolean | null

Other

License

MIT License

Copyright (c) 2018-2019 Maxim Alyoshin.

This project is licensed under the MIT License - see the LICENSE file for details.

Contributors

Thanks goes to these wonderful people (emoji key):


Maxim

πŸ’» 🎨 πŸ“– πŸ’‘ πŸ€” πŸ“’

Abu Shamsutdinov

πŸ’» πŸ’‘ πŸ€” πŸ‘€ πŸ“’

Sergey Sova

πŸ’» πŸ’‘ πŸ€” πŸ‘€ πŸ“’

Jussi Kinnula

πŸ› πŸ’»

RafaΕ‚ Wyszomirski

πŸ“–

Adrian CelczyΕ„ski

πŸ› πŸ’»

Alexey Olefirenko

πŸ’» πŸ€”

samholmes

πŸ’» πŸ€”

Ontopic

πŸ€”

Ryan Bell

πŸ€”

Bart Nagel

πŸ› πŸ’» πŸ’‘ πŸ€”

Greg McKelvey

πŸ’»

This project follows the all-contributors specification. Contributions of any kind welcome!


Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].