5.1.2 • Published 6 years ago

@styled-system/theme-get v5.1.2

Weekly downloads
40,010
License
MIT
Repository
-
Last release
6 years ago

@styled-system/theme-get

The themeGet function is an existential getter function that can be used in any style declaration to get a value from your theme, with support for fallback values. This helps prevent errors from throwing when a theme value is missing, which can be helpful when unit testing styled-components.

npm i @styled-system/theme-get
themeGet(objectPath, fallbackValue)(props)

themeGet returns a function that accepts props as an argument (themeGet(objectPath)(props)), which when used in a tagged template literal should look like this:

import styled from 'styled-components'
import { themeGet } from '@styled-system/theme-get'

const Box = styled.div`
  border-radius: ${themeGet('radii.small', '4px')};
`

When used with object literal syntax, themeGet needs to be in a function call and have props passed to it:

import styled from 'styled-components'
import { themeGet } from '@styled-system/theme-get'

const Box = styled('div')(props => ({
  borderRadius: themeGet('radii.small', '4px')(props),
}))
@yattho/gatsby-theme-rigitus@yattho/react@adapt-design-system/core@3wirebuild/styled-systemcunei-styled-ui@thesaurus/componentspa-temp-design-system@pixelmord/prestyledmy-test-vimal-componentsvtest-cmp@hack4impact-uiuc/design@blend-ui/testsui-gatsby@lotter-system/core@cuneilego/styled-elements@testing-ui/core@plum-xoxo/stores-dsm@everything-registry/sub-chunk-878@buoysoftware/anchor-themexdefi-common-uithree-divers-uiisland-uiisland-ui-systemhotel-nextlucas-test-design-systemmanoamasterpiece-uimdlz-prmtzlambdatestprimer@welina/manoa@twilio-labs/match@twilio-paste/styling-library@union/components@union/ts-components@thesaurusds/components@vashafarisi/react@yfi/design@zalastax/nolb-_styadonimals-uiapollos-web-embeds@nulogy/components@obigtech/ui@olist/ui-commons@olist/united@open-codes/opencodes@opencollective/frontend-components@pingux/astro@plum-xoxo/qib-dsmgatsby-theme-affiliategatsby-theme-careersgatsby-affiliate-themegatsby-theme-doctocatgatsby-theme-doctornpmgatsby-theme-primergatsby-theme-primer-wikigatsby-theme-gatsbyjs-websitegatsby-theme-wikinotes@sqymagma/theme@stacks/ui@sproutsocial/seeds-react-badge@system-one/react@system-one/rnw@syvita/ui@t3n/themeduodealer-design-systemelemental-reactdocz-theme-primer@aaiello/rimble-ui@primer/react@primer/components@primer/gatsby-theme-doctocat@prifina-apps/newmuzzler@bofink/ui@blasterjs/core@blend-ui/borderless-input@blend-ui/borderless-textarea@bonobolabs/mds-web-ui@bonobolabs/mds-web-ui-gatsby@bonobolabs/mds-web-ui-reach@blockstack/ui@bridgetool/gatsby-theme-dev@builder-plugins/core@cap-collectif/ui@catchandrelease/arbor@cbryant24/styled-react@chatterbug/aaron@class101/ui-system@bestyled/systemcomrade-components-reactconnect-atom-designchaser-componentschakra-uicl-design-systemcoppolacycloffix-test-design-system-2design-system-setupbdd-docsbig-design-uicabana-reactboina
5.1.2

6 years ago

5.1.1

6 years ago

5.1.0

6 years ago

5.0.21

6 years ago

5.0.18

6 years ago

5.0.16

6 years ago

5.0.15

6 years ago

5.0.12

6 years ago

5.0.6

6 years ago

5.0.5

6 years ago

5.0.4

6 years ago

5.0.3

6 years ago

5.0.2

6 years ago

5.0.1

6 years ago

5.0.0

6 years ago

5.0.0-12

6 years ago

5.0.0-11

6 years ago

5.0.0-7

6 years ago

5.0.0-alpha.0

6 years ago

5.0.0-5

6 years ago

5.0.0-3

6 years ago

5.0.0-2

6 years ago

5.0.0-1

6 years ago

5.0.0-0

6 years ago