PatternFly Java is a pure Java implementation of the PatternFly design system for building enterprise web applications. It provides a comprehensive set of UI components, layouts, icons, and design tokens that can be compiled to JavaScript using either GWT (Google Web Toolkit) or J2CL (Java-to-Closure-Compiler). The library is built on top of Elemento utilizing its fluent builder API for type-safe HTML element construction.
This page introduces the project's purpose, architecture, and key characteristics. For detailed information about the multi-module Maven structure and dependency relationships, see Project Architecture. For instructions on adding PatternFly Java to your application, see Getting Started.
Sources: pom.xml1-599 README.md1-310
PatternFly Java distinguishes itself through several key design principles:
| Characteristic | Description |
|---|---|
| Pure Java | All component logic implemented in Java with no manual JavaScript required |
| CSS Independence | Stylesheets are NOT bundled; developers must provide PatternFly CSS separately at runtime |
| Dual Compilation | Supports both GWT and J2CL compilation targets through dedicated integration modules |
| Type-Safe API | Leverages Elemento's builder pattern for compile-time safety and IDE autocomplete |
| Design Tokens | Includes ~1000 enum constants representing PatternFly design tokens as Token enum |
| Icon Generation | Icons generated at build time from Font Awesome and PatternFly NPM packages |
Chart Exception: Chart components require the @patternfly-java/charts NPM package, which wraps PatternFly React Chart components as web components. This is the only JavaScript dependency in the project.
Sources: README.md84-86 README.md89-104 pom.xml78-89
The project is organized as a multi-module Maven build with the following hierarchy:
Module Descriptions:
| Module | Artifact ID | Packaging | Purpose |
|---|---|---|---|
| Parent | patternfly-java-parent | pom | Root aggregator POM with plugin management |
| Code Parent | patternfly-java-code-parent | pom | Parent for all code modules; manages dependencies |
| BOM | patternfly-java-bom | pom | Bill of materials for dependency management |
| Core | patternfly-java-core | gwt-lib | BaseComponent, BaseComponentSVG, utility classes |
| Icons | patternfly-java-icons | gwt-lib | Generated icon classes from Font Awesome & PatternFly |
| Tokens | patternfly-java-tokens | gwt-lib | Generated Token enum from PatternFly CSS variables |
| Layouts | patternfly-java-layouts | gwt-lib | Layout components (Grid, Flex, Stack, etc.) |
| Components | patternfly-java-components | gwt-lib | All UI components (Button, Menu, Modal, etc.) |
| Charts | patternfly-java-charts | gwt-lib | Java API for PatternFly chart web components |
| Code Editor | patternfly-java-codeeditor | gwt-lib | Code editor extension component |
| Finder | patternfly-java-finder | gwt-lib | MacOS-style finder extension component |
| GWT | patternfly-java-gwt | gwt-lib | GWT module descriptor and resources |
| J2CL | patternfly-java-j2cl | jar | J2CL externs for type safety |
| Showcase | patternfly-java-showcase | jar | Demo application (J2CL-based) |
Sources: pom.xml113-126 README.md105-122 code-parent/pom.xml1-105
PatternFly Java builds upon several external libraries and follows a layered dependency structure:
Key Dependencies:
HTMLContainerBuilder, IsElement, etc.)HTMLElement, Event, Promise, etc.)gwt-user APIs)Sources: pom.xml78-89 core/pom.xml39-51 code-parent/pom.xml35-64
PatternFly Java supports two Java-to-JavaScript compilation approaches:
Applications using GWT compilation:
patternfly-java-gwt artifact (type: gwt-lib)org.patternfly.PatternFly module in their .gwt.xml filegwt-maven-plugin for compilationModule Descriptor: gwt/src/main/resources/org/patternfly/PatternFly.gwt.xml
Sources: gwt/pom.xml1-84 README.md75-81
Applications using J2CL compilation:
patternfly-java-j2cl artifact (type: jar)j2cl-maven-plugin for compilation with Closure optimizationcharts.externs.jsExterns File: j2cl/src/main/resources/META-INF/externs/charts.externs.js
Sources: j2cl/pom.xml1-63 showcase/pom.xml201-218
The component system follows a composition-based architecture with a common base class hierarchy:
Key Abstractions:
BaseComponent<E extends HTMLElement, B>: Foundation for all HTML-based componentsBaseComponentSVG<E extends SVGElement, B>: Foundation for SVG-based components (icons)SubComponent<E, B>: Base for sub-components like PageMain, PageGroupCloseable: Components with popup/overlay behavior (Modal, Popover, Tooltip)Attachable: Components using Popper.js for positioningHasItems<B, S>: Parent components managing child itemsHasIdentifier: Child components with unique identifiersSources: components/src/main/java/org/patternfly/component/page/PageMain.java1-164 README.md194-207
PatternFly Java generates several Java source files during the Maven build process:
Generated Files:
IconSets.java: Static factory methods for Font Awesome (fab, far, fas) and PatternFly iconsIconSpecs.java: SVG path data constants referenced by IconSetsToken.java: Enum constants for all PatternFly design tokens (name, value, var)Version.java: Project version and PatternFly version constantsBuild Plugins:
frontend-maven-plugin: Executes Node.js scripts for icon and token generationjbang-maven-plugin: Executes JBang Java scripts for version generationSources: icons/pom.xml59-94 core/pom.xml81-101 pom.xml78-89
Applications integrate PatternFly Java by importing the BOM and depending on either the GWT or J2CL module:
Integration Steps:
patternfly-java-bom in <dependencyManagement>patternfly-java-gwt (GWT apps) or patternfly-java-j2cl (J2CL apps)org.patternfly.PatternFly in .gwt.xmlpage(), button(), menu())@patternfly-java/charts NPM package for chart componentsSources: README.md38-87 bom/pom.xml83-201
The project follows semantic versioning and tracks both PatternFly Java and upstream PatternFly versions:
| Property | Value | Location |
|---|---|---|
| PatternFly Java Version | 0.4.18-SNAPSHOT | pom.xml31 |
| PatternFly Version | 6.4.0 | pom.xml88 |
| Elemento Version | 2.4.8 | pom.xml81 |
| Java Version | 21 | pom.xml106 |
Version Class: Generated at build time in core/src/main/java/org/patternfly/core/Version.java containing constants for programmatic access.
Sources: pom.xml31 pom.xml78-89 core/pom.xml81-101
Refresh this wiki
This wiki was recently refreshed. Please wait 5 days to refresh again.