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

  • 4.0.1
  • 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.

You can use it with emotion too

Demo Sandbox

code

fullscreen

Installation

Use yarn or npm

yarn add styled-breakpoints
npm i styled-breakpoints

Get Started

The following values of breakpoints are used by default.

const defaultBreakpoints = {
  tablet: '768px',
  desktop: '992px',
  lgDesktop: '1200px',
};
import styled from 'styled-components';
import { above, below, between, only } from 'styled-breakpoints';

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

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

Converts to pure css:

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

Above

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

Converts to:

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

Below

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

Converts to:

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

Between

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

Converts to:

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

Only

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

Converts 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 { above, below, between, only } = createBreakpoints({
  sm: '576px',
  md: '768px',
  lg: '992px',
  xl: '1200px',
});

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

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

License

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 12 Oct 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