# rxs

> Reactive CSS: Super fast dynamic CSS rules.

Latest version **0.4.1** (published 2017-04-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install rxs
pnpm add rxs
yarn add rxs
bun add rxs
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.1 |
| Published | 2017-04-11 |
| First published | 2017-04-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | ItsJonQ |
| Maintainers | itsjonq |

## Links

- npm: https://www.npmjs.com/package/rxs
- Repository: https://github.com/ItsJonQ/rxs
- Homepage: https://github.com/ItsJonQ/rxs#readme
- Issues: https://github.com/ItsJonQ/rxs/issues
- npm.io page: https://npm.io/package/rxs

## Recent versions

- 0.4.1 (latest) — 2017-04-11
- 0.4.0 — 2017-04-10
- 0.3.7 — 2017-04-10
- 0.3.6 — 2017-04-10
- 0.3.5 — 2017-04-09
- 0.3.4 — 2017-04-09
- 0.3.3 — 2017-04-09
- 0.3.2 — 2017-04-09
- 0.3.1 — 2017-04-09
- 0.3.0 — 2017-04-09
- 0.2.0 — 2017-04-09
- 0.1.1 — 2017-04-08

## README

<img src="https://raw.githubusercontent.com/ItsJonQ/rxs/master/images/rxs-logo-2x.png" width="111">

### rxs: Reactive CSS [![Build Status](https://travis-ci.org/ItsJonQ/rxs.svg?branch=master)](https://travis-ci.org/ItsJonQ/rxs) [![npm version](https://badge.fury.io/js/rxs.svg)](https://badge.fury.io/js/rxs)

Super fast dynamic CSS rules.<br>
Tiny and Dependency-free!

## Getting Started
```
npm install rxs --save
```


## Example Demo
Clone this repo, and open up:
* [example/index.html](https://jonquach.com/demos/rxs/neato.html) (Move your mouse around + resize window)
* [example/hero.html](http://jonquach.com/demos/rxs/hero.html) (Scroll)


## Quick Example

For this example, we want the height of any element with the class of `.fun-height` to be exactly 65% of the window's height, in `px`. It should also update everytime the browser is resized.

```html
<div class="card fun-height">
  ...
</div>

<!-- Add the reactive-css script -->
<script src="../js/rxs.min.js"></script>
```

In our Javascript, we'll define the Reactive CSS rule. We can set/update the rule by using the `.set()` method everytime the window is resized.

```js
// Add a new CSS rule to the Reactive Stylesheet
var funHeightCSS = rxs('.fun-height');

window.addEventListener('resize', function() {
  // Everytime the window is resized, update the height property for
  // the class `.fun-height` to a computed height
  funHeightCSS.set({
    height: (window.innerHeight * 0.65) + 'px',
  });
});
```

Alternatively, you can write the above in a slightly shorter way by passing the style properties as a second argument for `rxs()`:

```js
window.addEventListener('resize', function() {
  // Everytime the window is resized, update the height property for
  // the class `.fun-height` to a computed height
  rxs('.fun-height', {
    height: (window.innerHeight * 0.65) + 'px',
  });
});
```

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