# load-themed-styles

> Loads themed styles.

Latest version **1.2.0** (published 2016-07-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install load-themed-styles
pnpm add load-themed-styles
yarn add load-themed-styles
bun add load-themed-styles
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2016-07-08 |
| First published | 2016-02-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | dzearing |

## Links

- npm: https://www.npmjs.com/package/load-themed-styles
- Repository: https://github.com/dzearing/load-themed-styles
- Homepage: https://github.com/dzearing/load-themed-styles#readme
- Issues: https://github.com/dzearing/load-themed-styles/issues
- npm.io page: https://npm.io/package/load-themed-styles

## Recent versions

- 1.2.0 (latest) — 2016-07-08
- 1.1.0 — 2016-05-12
- 1.0.6 — 2016-04-07
- 1.0.4 — 2016-02-28
- 1.0.3 — 2016-02-25
- 1.0.1 — 2016-02-24
- 1.0.0 — 2016-02-24

## README

# load-themed-styles [![npm version](https://badge.fury.io/js/load-themed-styles.svg)](https://badge.fury.io/js/load-themed-styles)

[![Build Status](https://travis-ci.org/dzearing/load-themed-styles.svg?branch=master)](https://travis-ci.org/dzearing/load-themed-styles) [![Dependencies](https://david-dm.org/dzearing/load-themed-styles.svg)](https://david-dm.org/dzearing/load-themed-styles)

> Loads a string of style rules, but supports detokenizing theme constants built within it.

## Install

Install with [npm](https://www.npmjs.com/)

```
$ npm install --save load-themed-styles
```

## Usage

To load a given string of styles, you can do this:

```js
import { loadStyles } from 'load-themed-styles';

loadStyles('body { background: red; }');
```

This will register any set of styles given. However, in the above example the color is hardcoded to red. To make this theme-able, replace it with the string token in this format:

```
"[theme:{variableName}, default:{defaultValue}]"
```

For example:

```js
loadStyles('body { background: "[theme:primaryBackgroundColor, default: blue]"');
```

When loading, the background will use the default value, blue. Providing your own theme values using the `loadTheme` function:

```js
import { loadStyles, loadTheme } from 'load-themed-styles';

loadTheme({
  primaryBackgroundColor: "#EAEAEA"
});

loadStyles('body { background: "[theme:primaryBackgroundColor, default: #FFAAFA]"');
```

This will register #EAEAEA as the body's background color. If you call loadTheme again after styles have already been registered, it will replace the style elements with retokenized values.

## License

MIT © [David Zearing](http://github.com/dzearing)

---
_Source: https://npm.io/package/load-themed-styles · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
