# theme-tweaker

> Made with create-react-library

Latest version **1.1.1** (published 2021-08-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install theme-tweaker
pnpm add theme-tweaker
yarn add theme-tweaker
bun add theme-tweaker
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2021-08-16 |
| First published | 2021-08-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 0 |
| Unpacked size | 28.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | guygolanIL |
| Maintainers | guygolanil |

## Links

- npm: https://www.npmjs.com/package/theme-tweaker
- Repository: https://github.com/guygolanIL/theme-tweaker
- Homepage: https://github.com/guygolanIL/theme-tweaker#readme
- Issues: https://github.com/guygolanIL/theme-tweaker/issues
- npm.io page: https://npm.io/package/theme-tweaker

## Recent versions

- 1.1.1 (latest) — 2021-08-16
- 1.1.0 — 2021-08-16
- 1.0.0 — 2021-08-15

## README

# theme-tweaker

> Use to develop your Theme object dynamically

[![NPM](https://img.shields.io/npm/v/theme-tweaker.svg)](https://www.npmjs.com/package/theme-tweaker) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

## Install

```bash
npm install --save theme-tweaker
```

## Usage

### Basic Example
```tsx
// index.tsx
import './index.css'

import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'
import {createThemeTweaker} from 'theme-tweaker'

export type Theme = {my: string};
const theme: Theme = {my: 'theme'};

const Provider = createThemeTweaker();

ReactDOM.render(
    <Provider theme={theme}>
        <App />
    </Provider>
, document.getElementById('root'))

```

## Using a third party library (Material UI for example)
### Pass that library theme provider to the createThemeTweaker function and use the returned Provider the same way.
```tsx
// index.tsx
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import {theme} from './theme/theme';
import MuiProvider from '@material-ui/styles/ThemeProvider';
import { createThemeTweaker } from './theme/themeTweaker/themeTweaker';

const isDev = process.env.NODE_ENV === "development";

const ThemeProvider = isDev ? createThemeTweaker(MuiProvider) : MuiProvider; 

ReactDOM.render(
    <ThemeProvider theme={theme}>
        <App />
    </ThemeProvider>
,
  document.getElementById('root')
);
```

## Modifying your theme from a component
```tsx
import {useThemeTweaker} from 'theme-tweaker';
import React from 'react';
import {Theme} from './index';

const App = () => {
  const {theme, setThemeProp} = useThemeTweaker<Theme>();
  
  return (
    <div>
      <button onClick={() => setThemeProp("my", "edited theme")}>Change</button>
      {JSON.stringify(theme)}
    </div>
  );
}

export default App
```
## License

MIT © [guygolanIL](https://github.com/guygolanIL)

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