Start Developing
Before you begin
For all new applications you are good to continue with the install guide.
For existing applications there are some helpful guides available in order to upgrade to v5.
Start by configuring your registry
Before you can install the chroma components locally you will need to configure your .npmrc
file like the example below.
.npmrc
registry=https://nexus3.auiag.corp/repos/repository/iag-npm-all/
legacy-peer-deps=true
.yarnrc.yml (optional)
If you use yarn then you may need the following in your .yarnrc.yml
npmRegistryServer: "https://nexus3.auiag.corp/repos/repository/iag-npm-all/"
Install the Package
We recommend using the bundled package
Bundled Package
The bundled package includes all chroma components within a single packaged version.
yarn add @iag/chroma-react-ui.components
Individual Packages (optional)
If you have a smaller application and only require a few components you can install them individually, however we recommend using the bundled package for larger applications.
yarn add @iag/chroma-react-ui.brand-provider
yarn add @iag/chroma-react-ui.alert
yarn add @iag/chroma-react-ui.button
etc....
Using the components in your app
Using the Chroma component package is the same as any other NPM package.
Import the brand provider and alert components
import { BrandProvider, Alert } from "@iag/chroma-react-ui.components";
Make sure to set a brand
for the brand provider to work correctly.
More info can be found in the brand provider component page.
import { BrandProvider, Alert } from "@iag/chroma-react-ui.components";
import "./styles.css";
function App() {
const brand = "chroma";
return (
<div className="App">
<BrandProvider brand={brand}>
<h1 className="text-primary">Heading</h1>
<Alert variant="information" className="mb-3">
<h3>Information Alert</h3>
<p>Information alert content</p>
</Alert>
</BrandProvider>
</div>
);
}
export default App;
At this step you should be able to see an alert component styled within your application.
Add Tailwind CSS to generate the utility styling
Chroma uses Tailwind CSS to generate all the utility classes for styling.
Tailwind CSS also integrates seamlessly with our brand tokens, and best of all it's easy to setup and use within your application.
Install Tailwind CSS
Start by installing the tailwind package.
npm install -D tailwindcss postcss autoprefixer