GithubHelp home page GithubHelp logo

georgemarshall / react-css-theming Goto Github PK

View Code? Open in Web Editor NEW

This project forked from matkrzy/react-css-theming

0.0 1.0 0.0 161 KB

A library that allows you to make your application themeable based on css variables in an easy way without additional components and wrappers

License: MIT License

JavaScript 13.63% TypeScript 86.37%

react-css-theming's Introduction

react-css-theming

A library that allows you to make your application themeable based on css variables in an easy way without additional components and wrappers

#Usage Use ThemeProvider to provide defined css variables into the application like below

import { ThemeProvider } from 'react-css-theming';

import styles from './styles.scss';

//defined themes and variables
const themes = {
  default: {
    primary: 'red',
  },
  second: {
    primary: 'yellow',
  },
};

export const App = () => {
  return <ThemeProvider themes={themes}>....</ThemeProvider>;
};

Use defined variables in your styles files

.app {
  color: var(--primay);
}

#Props list List of ThemeProvider props

name type default value required desc
themes Object - yes object with defined themes and variables
defaultTheme string default no default theme which will be applied as default

useTheme hook

If you want to have access to update theme in any place of the application you can use useTheme hook

import { useTheme } from 'react-css-theming';

const MyComponent = () => {
  const { theme, change, themes } = useTheme();

  //....
};

Hook values

name type desc
theme string selected theme
change (string)=>void function to update selected theme where arg is a string with new theme
themes string[] array of available themes

react-css-theming's People

Contributors

matkrzy avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.