Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hig/theme-context

Package Overview
Dependencies
Maintainers
7
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hig/theme-context

ThemeContext components to ease adoption of theme data from React components

  • 1.0.0-alpha.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
223
decreased by-57.28%
Maintainers
7
Weekly downloads
 
Created
Source

ThemeContext component

Themable HIG components within a ThemeContext.Provider will have access to the provided theme.

Getting started

yarn add @hig/themes

Provide a theme to components

import HIGDarkBlueTheme from '@hig/theme-data/build/darkBlueMediumDensity/theme.json';
import ThemeContext from '@hig/theme-context';

function MyApp() {
  <ThemeContext.Provider value={HIGDarkBlueTheme}>
    <TheRestOfMyApp />
  </ThemeContext.Provider>
}

Consume theme values in a component

import ThemeContext from '@hig/themes';

function MyThemedComponent() {
  <ThemeContext.Consumer>{({ resolvedRoles, name }) => (
    <div style={{
      backgroundColor: resolvedRoles["colorScheme.surfaceLevel20Color"],
      borderRadius: resolvedRoles["basics.borderRadii.small"],
      color: resolvedRoles["colorScheme.textColor"],
      padding: resolvedRoles["density.spacings.medium"],
    }}>
      The current theme is "{name}".
    </div>
  )}</ThemeContext.Consumer>
}

FAQs

Package last updated on 29 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc