This project is not covered by Drupal’s security advisory policy.

A Drupal theme for PatternFly 6, Red Hat's open source design system, ready to be used by Display Builder. It needs core only and ships PatternFly 6.7.0.

PatternFly is a Red Hat project. This theme is not affiliated with or endorsed by Red Hat.

Requirements

  • Drupal 11.3 or later. Nothing else is required.
  • Suggested: Display Builder, Display Builder Page Layout for the page layout, UI Patterns 2 for stories and sources, UI Skins to force the dark color scheme, Generic Components for HTML wrappers.

Install

Install the theme with Composer, then enable it.

By default PatternFly loads from the jsDelivr CDN, with an integrity hash. The CDN also serves the Red Hat fonts. To serve everything from your own site, add the npm package. The site needs asset-packagist as a Composer repository, and an installer-paths entry that maps npm-asset packages to web/libraries/{$name}.

composer require npm-asset/patternfly--patternfly:6.7.0

The package lands in web/libraries/patternfly--patternfly. Then set Source to Local in the theme settings. The option stays hidden until the files exist. The CSS loads its fonts by relative path, so they follow the source.

Icons

The theme defines one icon pack for the core Icon API, pficons. It reads PatternFly's own SVG icons from /libraries/patternfly--patternfly/icons/PfIcons/. The theme bundles none of them. Without the library, the pack is empty. The component chrome icons, such as close and caret, are inline SVG and need nothing.

Styles

patternfly.ui_styles.yml offers 30 patternfly_ styles on PatternFly's utility classes: margin and padding per side, text size, weight, alignment, wrapping, family and color, background color, shadow, display, flexbox, and hidden always or from a size. They need patternfly-addons.css, which the theme loads after the main file, from the same source: CDN with its own integrity hash, or /libraries/.

Dark skin

Without a skin, PatternFly is light. The UI Skins theme patternfly_dark adds pf-v6-theme-dark to the root html element. Skin IDs are global, so the prefix avoids clashes.

Components

Accordion, accordion item, alert, badge, banner, breadcrumb, button, button group, card, close button, content, divider, dropdown, empty state, gallery, grid 2 to 4, heading, hero, hint, level, list, masthead, modal, nav, pagination, progress, skeleton, spinner, stack, tab item, table and tabs. That is 34.

  • Page layout: gallery and grid 2 to 4.
  • Layout and text: card, content, divider, heading, list, empty state, hint and banner. The card's "Full height?" fills its cell, so cards side by side are equally tall.
  • Layout classes: stack and level, with an optional gutter, and the hero.
  • Actions: button, button group, close button and dropdown.
  • Feedback: alert, badge, progress, skeleton and spinner.
  • Navigation and disclosure: masthead, nav, pagination, accordion, accordion item, breadcrumb, tabs, tab item and modal.
  • Data: table.

Some details:

  • A button with "modal_target" set to a modal's ID opens that modal.
  • An alert with "Dismissible?" set shows a close button that removes it.
  • The dropdown takes its links as props.
  • The table takes its caption, header cells and rows as props.
  • Tabs take tab_item components. The tab list is built from their labels.
  • The accordion takes accordion_item components.
  • Gallery is PatternFly's gallery layout. Its items wrap at a minimum width, 250 px unless "Minimum column width" sets one in rem.
  • Grid 2 and grid 3 are PatternFly's grid, with widths as variants. Their columns sit side by side from 768 px. Grid 4 has two columns from 768 px and four from 992 px.
  • The masthead takes the brand and its content as slots. With "Brand URL" set, the brand links there.
  • The nav takes its items as props, with one level below. Fill them with the menu source. In the vertical variant, an item with children is a group that opens. A parent with a URL repeats as its group's first link, because the toggle cannot link. The horizontal variant prints the top level only, as PatternFly 6 has no horizontal submenu. On narrow screens it scrolls sideways.
  • The pagination has first, previous, next and last buttons, and "Page N of M". PatternFly has no page numbers. The compact variant has previous and next only.

PatternFly ships no JavaScript. js/patternfly.js is one delegated script that adds these behaviors, with no Drupal behavior to attach. Clicks are caught in the capture phase, because Display Builder's Canvas stops their propagation.

  • Alert dismissal. A [data-patternfly-dismiss] button removes its alert. In the Canvas it does nothing, because the Canvas re-renders from the builder state.
  • Accordion toggles show or hide their content and set the expanded class.
  • Vertical nav group toggles show or hide their subnav.
  • Dropdown toggles open their menu as a disclosure, with no arrow keys. A click outside or Escape closes it.
  • Modals open from [data-patternfly-modal-open] on a native dialog. They close from the backdrop, the close button or [data-patternfly-modal-close]. A drag that ends on the backdrop does not close them.
  • Tabs build one tab per tab_item panel at load, and again on every change inside a [data-patternfly-tabs] root. Display Builder runs no behaviors in its Canvas, so a MutationObserver does it.

Templates

The theme renders core's page parts with PatternFly:

  • Status messages are an alert group, one inline alert per type. Several messages of one type are a list in their alert. js/messages.js gives messages added by JavaScript the same markup, one alert per message.
  • The pager uses the pagination component, with "Page N of M". The Views mini pager uses its compact variant. Core's link attributes are lost: the component takes URLs only.
  • Local tasks are PatternFly tabs, secondary tasks subtabs. They are links, not a tablist.
  • The breadcrumb uses the breadcrumb component.

Forms

Core's form elements get PatternFly's form classes: form groups, labels with the required marker, form controls, checks, radios, helper text and form actions. Fieldsets are form groups. An error adds the error state and its helper text. Buttons are PatternFly buttons, primary, danger or secondary. A form whose buttons have no type gets a primary: its first submit. File, range and color inputs keep the browser's look.

Display Builder's own forms keep their look. The theme skips its HTMX routes and its admin builder pages. The Canvas and the library previews are front pages, so their forms get PatternFly's classes.

Display Builder

  • config/optional holds a patternfly profile and a patternfly page layout for pages in the PatternFly theme. They install with Display Builder. The profile hides Display Builder's own components from the library. The page layout also needs Display Builder Page Layout and Generic Components. It is PatternFly's page with a horizontal nav: a masthead with the site name and the main menu, then the breadcrumb, messages, page title, tabs and content, then a footer. An empty page title prints no box.
  • config/optional also holds 17 presets: a hero, sections, cards, layouts, page parts and article parts. Presets built from HTML wrappers need Generic Components: the site footer and page frame. The article header needs the article content type, the article teaser also its body field. The page frame needs Display Builder Page Layout. The site header, site footer and page frame are the page layout's parts.
  • Presets print PatternFly markup only. The theme loads PatternFly's CSS and JavaScript as global libraries, and its components attach none. So the presets look right only on pages in the PatternFly theme.
  • Display Builder renders its interface in the admin theme. The Builder iframe and the previews are front pages, so PatternFly's global rules reach them. The Canvas fixes live in assets/css/canvas.css, each scoped to .db-island-builder. The Builder renders no slot dropzone, so no rule targets one.
  • The Canvas shows the content of every accordion item and tab panel, so you can fill it. It also shows every nav group, and closed modals in the flow.

Known limitations

  • The document scrolls, not PatternFly's page frame. PatternFly's page main keeps its overflow: auto, so it holds sticky page sections, and it never scrolls. pf-m-sticky-top and pf-m-sticky-bottom do not stick.
  • Inline forms, such as Views exposed filters, stack their fields. PatternFly's form is a grid, and core adds no inline class to them. PatternFly's filter bar is the toolbar, which the theme does not provide. A form in the masthead, the search block, is the exception: it sits on one row.
  • PatternFly marks the hero beta. The hero preset may change with it.
  • The hero preset's heading is an h1. On a page with a title, the page has two h1s.

Maintainers

assets/css/classes.txt is generated from the pinned PatternFly package and the theme's CSS. After changing either, run:

npm --prefix scripts install
npm --prefix scripts run classes

npm --prefix scripts test runs the script tests.

Credits

PatternFly, by Red Hat, MIT license. The Red Hat fonts are under the SIL Open Font License with a Reserved Font Name. The theme never renames or modifies them. PF icons are MIT.

Rebuilt on the 2024 and 2025 work of celdia, the project's creator, with fixes from Pierre Dureau. The component list and the idea of wrapping PatternFly as Display Builder components come from celdia's accordion, alert, badge, banner, breadcrumb, button and card.

Changes from celdia's 1.0.x

This rebuild replaces the 1.0.x code. Rebuild displays that used the old components.

  • The theme needs Drupal 11.3. 1.0.x allowed ^10 || ^11.
  • The ui_patterns dependency is gone. The theme is core only. Composer requires only drupal/core.
  • page and tile are removed. The page frame is now the patternfly page layout and the page frame preset. PatternFly 6 deprecates tile.
  • masthead is rebuilt. Its main and logo slots are now one brand slot, and the logo_url prop is brand_url.
  • The page and UI Patterns library templates are removed, and so are the block placements in config/optional. The breadcrumb and status messages templates are rebuilt, under templates/navigation and templates/misc.
  • 1.0.x already used PatternFly 6.0.0 and pf-v6, except in accordion and tile, which kept pf-v5 classes. Accordion now uses pf-v6, and the PatternFly version is 6.7.0.
  • The regions header_main, header_logo and header_content are gone. The regions are now header, sidebar, content and footer.
  • patternfly-addons.css was not loaded in 1.0.x. It is again, as its own library, and patternfly.ui_styles.yml is rebuilt on it.
  • The library patternfly/patternfly_cdn is renamed patternfly/framework_css. The theme also adds theme, canvas and framework_js.
  • New components: button group, close button, content, divider, dropdown, empty state, gallery, grid 2 to 4, heading, hint, list, modal, nav, pagination, progress, skeleton, spinner, tab item, table and tabs.

Support

Enjoying this project? Back my open source work on Liberapay: every contribution keeps it maintained.

Need a feature, a fix or a hand on your Drupal project? I take sponsored work and freelance missions. Let's talk.

Project information

Releases