Install
Install Fuegokit in your project with your package manager of choice.
With npm
npm install @fuegokit/react
With yarn
yarn add @fuegokit/react
Fuegokit is published using Appfire's internal npm registry. Your team lead should have provided you with the credentials you need. To get the proper credentials, follow the instructions here.
Usage
Once you install the package, you can import Fuegokit React components into your application using ES Module import
syntax:
// ES Modulesimport {Box, Text, ThemeProvider} from '@fuegokit/react'
Or using CommonJS require
syntax:
// CommonJSconst {Box, Text, ThemeProvider} = require('@fuegokit/react')
Peer dependencies
Fuegokit ships with a few libraries labeled as peer dependencies. These are libraries we've separated and don't bundle, because they're commonly installed in a host project consuming Fuegokit React, and having multiple versions can introduce errors.
Fuegokit requires the following libraries to be installed along with it:
styled-components
at version 5.0.0 or higherreact
at versions 17.0.2 or higherreact-dom
at versions 17.0.2 or higher
Install Fuegokit React with peer dependencies:
npm install @fuegokit/react react@17.0.2 react-dom@17.0.2 styled-components@5.0.0// oryarn add @fuegokit/react react@17.0.2 react-dom@17.0.2 styled-components@5.0.0
Global styles
To define global styles using styled-components
, add a GlobalStyles
component, and use Fuegokit's design tokens to define global variables:
import {createGlobalStyle} from 'styled-components'import {themeGet} from '@fuegokit/react'export const GlobalStyles = createGlobalStyle`* {margin: 0;}body, html, #root {height: 100%
Using ThemeProvider
Add Fuegokit React’s ThemeProvider to the root of your application. Include the BaseStyles
component that ships with Fuegokit React.
You can optionally include theme providers from other tools.
import React from 'react'import ReactDOM from 'react-dom'import App from './App'import {BaseStyles, ThemeProvider} from '@fuegokit/react'import {GlobalStyles} from './components'import {OtherThemeProvider} from 'some-other-ui-library-or-state-management-library'ReactDOM.render(
Compose components
Compose components using design system theme values.
import {Box, Text, themeGet} from '@fuegokit/react'const MyComponent = ({children, ...props}) => {return (<StyledBox><Text as="h2">{children}</Text></StyledBox>)}