Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

styled-breakpoints

Package Overview
Dependencies
Maintainers
1
Versions
183
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

styled-breakpoints

Simple and powerfull css breakpoints for styled-components

  • 2.0.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11K
decreased by-22.28%
Maintainers
1
Weekly downloads
 
Created
Source

styled-breakpoints

Simple and powerfull css breakpoints for styled-components.

Installation

Use yarn or npm

yarn add styled-breakpoints
npm i styled-breakpoints

Get Started

The following values of breakpoints are used by default.

{
  tablet: '768px',
  desktop: '992px',
  lgDesktop: '1200px',
}
import styled from 'styled-components';
import media from 'styled-breakpoints';

const Test = styled.div`
  background-color: pink;

  ${media.above('tablet')`
    background-color: hotpink;
  `};
`;

Convert to pure css:

div {
  background-color: pink;
}
/* 768px / 16px */
@media screen and (min-width: 48em) {
  div {
    background-color: hotpink;
  }
}

Above

  ${media.above('tablet')`
    background-color: hotpink;
  `};

Convert to:

@media screen and (min-width: 48em) {
  div {
    background-color: hotpink;
  }
}

Below

  ${media.below('desktop')`
    background-color: lightcoral;
  `};

Convert to:

/* (1200px - 0.02px) / 16px */
@media screen and (max-width: 74.99875em) {
  div {
    background-color: lightcoral;
  }
}

Between

  ${media.between('tablet', 'desktop')`
    background-color: hotpink;
  `};

Convert to:

/* 778px / 16px                  (1200px - 0.02px) / 16px */
@media screen and (min-width: 48em) and (max-width: 74.99875em) {
  div {
    background-color: hotpink;
  }
}

Only

  ${media.only('tablet')`
    background-color: rebeccapurple;
  `};

Convert to:

/*
  778px / 16px                  (992px - 0.02px) / 16px */
@media screen and (min-width: 48em) and (max-width: 61.99875em) {
  div {
    background-color: rebeccapurple;
  }
}

Custom breakpoints

import styled from 'styled-components';
import { createBreakpoints } from 'styled-breakpoints';

const media = createBreakpoints({
  sm: '576px',
  md: '768px',
  lg: '992px',
  xl: '1200px',
});

const Test = styled.div`
  background-color: pink;

  ${media.above('md')`
    background-color: hotpink;
  `};
`;

MIT License

Copyright (c) 2018 Maxim Alyoshin

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Keywords

FAQs

Package last updated on 21 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc