Skip to content
This repository has been archived by the owner on Jun 6, 2022. It is now read-only.

ljosberinn/react-rbx-bulmaswatch-theming-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Usage

  • add default theme to index.html->head with a "data-app-theme" property
 <link
 rel="stylesheet"
 href="//unpkg.com/bulmaswatch/THEME_NAME/bulmaswatch.min.css"
 data-app-theme="1"
 />
  • import ThemeContext from Theme.tsx and use it via React.useContext(ThemeContext)
import React, { useContext } from 'react';
import { ThemeContext } from './Theme';

const MyComponent = () => {
  const { AVAILABLE_THEMES, setTheme, theme } = useContext(ThemeContext);

  return (
    <ul>
      {AVAILABLE_THEMES.map(theme => <li key={theme}>{theme}</li>)}
    </ul>
  );
}

export default MyComponent;

Releases

No releases published

Packages

No packages published