Develop with PatternFly

Getting started

In order to develop with PatternFly, you will need to:

  1. Learn about the PatternFly design system to get acquainted with all of its elements.

  2. Learn about our design token system, which enables you to build interfaces with consistent PatternFly styling, including colors, shadows, spacing, and more.

  3. Install a package manager to help you install, update, and configure all necessary PatternFly packages. We recommend npm or Yarn.

  4. Configure your environment to get started with our React and/or HTML/CSS libraries.

Develop with React

PatternFly's React library contains a collection of components that you can use to build interfaces with consistent markup, styling, and behavior. It is composed of a number of React packages, which are published in the following npm packages:

These packages are maintained together. To determine which versions of each package are compatible with the rest, view our release highlights.

We support the following configurations:

Install and configure PatternFly React

New projects

If you'd like to start using PatternFly via a sample project, you can use the PatternFly React seed. We created this open-source build scaffolding utility to help developers jump start new PatternFly projects.

To get started:

  1. Fork the React seed:

    For more information about how to fork and clone a repo, view GitHub Help.

  2. Install the project:

    Follow the steps outlined in the React seed README to install.

Existing projects

If you wish to migrate an existing project to PatternFly you must install and configure PatternFly React using either of these methods:

  • Using npm, run the following command:

    npm install @patternfly/react-core --save
  • Using Yarn, run the following command:

    yarn add @patternfly/react-core

Develop with HTML/CSS

The PatternFly HTML/CSS library contains a collection of code samples that you can use to build interfaces with consistent PatternFly markup and styling.

Each of the 3 modules (layouts, components, and utilities) delivers Sass (.scss) and CSS files that you can include in your build environment or consume from your page header. If you need to overwrite any elements, we recommend extending the variables found in the Sass files, rather than manually overwriting the CSS.

When you install PatternFly, the package includes:

  • A single file for the entire compiled library: node_modules/@patternfly/patternfly/patternfly.css
  • Individual files with each component compiled separately: node_modules/@patternfly/patternfly/<ComponentName>/styles.css
  • A single file for the entire library's source: node_modules/@patternfly/patternfly/patternfly.scss
  • Individual files for each component's source: node_modules/@patternfly/patternfly/<ComponentName>/styles.scss

Use these files to consume the library. The recommended consumption approach will vary from project to project.

Install and configure PatternFly HTML/CSS

  1. Using npm, run the following command to install the HTML/CSS library:

    npm install @patternfly/patternfly --save
  2. Navigate to the package you just installed to find the PatternFly CSS stylesheet, patternfly.css, and copy it into your project's CSS directory.

  3. In your HTML file, link to your new PatternFly stylesheet by adding the following line to the bottom of your list of CSS files:

    <link rel="stylesheet" href="css/patternfly.css">

    This will ensure that PatternFly styles take precedence over anything that currently resides in your application.

  4. If you want to use PatternFly utilities in your project, find the utilities file, patternfly-addons.css, and copy it into your project’s CSS directory.

  5. In your HTML file, add the following line to the bottom of your list of CSS files:

    <link rel="stylesheet" href="css/patternfly-addons.css">

Using icons

PatternFly uses Font Awesome 5, which can be utilized in 2 different ways:

  • Built into PatternFly: By default, Font Awesome is included as part of the PatternFly CSS file. You do not need to do anything else to use this icon font family.

  • Used as a CDN: If you wish to use the CDN for Font Awesome 5 rather than the default approach, you need to complete the following steps:

    1. Update the sass-utilities/scss-variables.scss file (from source node_modules/@patternfly/patternfly/) to include:

      $pf-v6-global--enable-fontawesome-cdn: true !default;
    2. Build PatternFly as part of your build process.

Testing

Many PatternFly components comply with the Open UI Automation (OUIA) guidelines, which are designed to ease the burden of creating and maintaining automated testing environments. Additional details about OUIA and the full list of compliant components can be found in our developer resources.

Supported browsers and operating systems

PatternFly is supported on the 2 latest major versions of the following browsers:

  • Chrome
  • Firefox
  • Safari
  • Edge