Skip to content

Latest commit

 

History

History
42 lines (29 loc) · 947 Bytes

README.md

File metadata and controls

42 lines (29 loc) · 947 Bytes

🎨 use-styled-theme

React hook for getting Styled Components theme values.

NPM JavaScript Style Guide

Install

npm i use-styled-theme || yarn add use-styled-theme

Usage

import React from 'react'
import { ThemeProvider } from "styled-components";
import useStyledTheme from 'use-styled-theme'

const Component = () => {
  const { color } = useStyledTheme();

  return (
    <div style={{ backgroundColor: color }}>
      <h1>{color}</h1>
    </div>
  );
};

const App = () => (
  <ThemeProvider theme={{ color: "#BADA55" }}>
    <Component />
  </ThemeProvider>
);

Example available on Codesandbox

License

MIT © markoradak