# @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 version **5.1.2** (published 2019-09-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install @styled-system/theme-get
pnpm add @styled-system/theme-get
yarn add @styled-system/theme-get
bun add @styled-system/theme-get
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.1.2 |
| Published | 2019-09-11 |
| First published | 2019-05-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/styled-system__theme-get) |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 3.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Brent Jackson |
| Maintainers | jxnblk |

## Links

- npm: https://www.npmjs.com/package/@styled-system/theme-get
- npm.io page: https://npm.io/package/@styled-system/theme-get

## Dependencies (1)

- [@styled-system/core](https://npm.io/package/@styled-system/core.md) ^5.1.2

## Recent versions

- 5.1.2 (latest) — 2019-09-11
- 5.0.0-12 (next) — 2019-06-02
- 5.0.0-alpha.0 (alpha) — 2019-05-28
- 5.1.1 — 2019-08-22
- 5.1.0 — 2019-08-12
- 5.0.21 — 2019-08-08
- 5.0.18 — 2019-07-31
- 5.0.16 — 2019-07-22
- 5.0.15 — 2019-07-15
- 5.0.12 — 2019-06-25
- 5.0.6 — 2019-06-10
- 5.0.5 — 2019-06-03
- 5.0.4 — 2019-06-03
- 5.0.3 — 2019-06-03
- 5.0.2 — 2019-06-02
- … 9 more at https://npm.io/package/@styled-system/theme-get/versions

## README

# @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.

```sh
npm i @styled-system/theme-get
```

```js
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:

```js
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:

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

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

---
_Source: https://npm.io/package/@styled-system/theme-get · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
