From 0db488dcf09c6e068e230bc57d7b030930013de5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Wyszomirski?= Date: Sun, 15 Mar 2020 19:14:08 +0100 Subject: [PATCH] feat: Add example for using the library with object notation (#533) --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index 06f33897..8bbde329 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,26 @@ const Component = styled.div` ; ``` +### Object notation + +When using object notation, make sure to explicitly pass `props` to breakpoint +methods. Please see the example below using default configuration: + +```js +import styled from 'styled-components'; +import { down, between } from 'styled-breakpoints'; + +const Component = styled('div')(props => ({ + color: 'black', + [down('tablet')(props)]: { + color: 'lightcoral' + }, + [between('sm', 'md')(props)]: { + color: 'hotpink' + } +})) +``` + ## API All incoming values are converted to em.