Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@class101/styled-system__theme-get

Package Overview
Dependencies
Maintainers
17
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@class101/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 helpf

latest
npmnpm
Version
5.3.3
Version published
Maintainers
17
Created
Source

@class101/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 @class101/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 '@class101/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 '@class101/styled-system__theme-get'

const Box = styled('div')(props => ({
  borderRadius: themeGet('radii.small', '4px')(props),
}))

FAQs

Package last updated on 01 Nov 2021

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