diff --git a/packages/documentation-site/patternfly-docs/content/foundations-and-styles/styles/colors/colors.md b/packages/documentation-site/patternfly-docs/content/foundations-and-styles/styles/colors/colors.md index 6a77d020d9..bc46c99614 100644 --- a/packages/documentation-site/patternfly-docs/content/foundations-and-styles/styles/colors/colors.md +++ b/packages/documentation-site/patternfly-docs/content/foundations-and-styles/styles/colors/colors.md @@ -190,6 +190,8 @@ Status and state colors are indicators that communicate data and actions to user To check the contrast between background and text colors, use a WCAG AA-compliance tool. +Beyond our standard contrast ratio, we support a high contrast and a glass contrast mode, as documented in our [theming guidelines](http://localhost:8003/foundations-and-styles/theming#contrast-modes). + ## Color families Our color palettes are organized into "families" that contain different shades of the same hue. In the following families, you can expand each color to see related tokens. diff --git a/packages/documentation-site/patternfly-docs/content/foundations-and-styles/styles/theming/glass-mode-handbook.md b/packages/documentation-site/patternfly-docs/content/foundations-and-styles/styles/theming/glass-mode-handbook.md new file mode 100644 index 0000000000..bf92554f08 --- /dev/null +++ b/packages/documentation-site/patternfly-docs/content/foundations-and-styles/styles/theming/glass-mode-handbook.md @@ -0,0 +1,66 @@ +--- +id: Theming +section: foundations-and-styles +source: glass-mode-handbook +--- + +# Glass mode developer handbook + +## What is glass mode? + +Glass mode is a contrast mode option that's enabled in our Felt theme by default and can be manually enabled in our Default theme. Glass adds transparency, blurring, and depth to the UI to create a more dynamic visual effect where brand-approved background images and layered UI elements subtly show through. + +When turned on, glass applies to the following components, including their uses within our extensions: +- Card +- Drawer +- Login page +- Masthead +- Navigation (docked) +- Page +- Panel + +### Background images + +The glass effect is most visible when placed over a background image. Background images should be selected or designed for each Red Hat product in collaboration with the Brand team. To retain readability and ensure proper contrast ratios are met, images shouldn't contain high levels of detail or extreme contrast. + +Text must never be placed directly on a background image—it should be placed within a container that has a background color or glass effect. Titles or headings with stronger font weights can be placed directly on background images only if they pass specific brand and contrast requirements. + +### Opacity + +The default opacity values used in our components have been tested for accessibility, legibility, and visual appeal. +- Felt light typically utilizes a 40% opacity to maintain AAA contrast for standard text. +- Felt dark utilizes a 60% opacity to provide better reliability for the dark color scheme. + +If a product team chooses to override these token values, they are responsible for conducting their own accessibility evaluation to ensure WCAG compliance. + +## Enabling glass mode + +Glass mode is designed to work across light and dark color schemes and is enabled by default in our Felt theme. To manually enable glass in our Default theme, add the class `.pf-v6-theme-glass` to your application’s `` tag. When implementing glass with our Default theme, it's important to ensure that glass does not harm the overall accessibility or usability of your product. + +### Technical constraints + +There are a few technical constraints to abide by when using glass in your product. + +- **No glass-on-glass layering:** Never layer glass-enabled containers. Doing so can cause significant performance and accessibility problems. For example, child objects inside a blurred parent container can become illegibly blurred themselves. To mitigate this, we have intentionally adjusted the opacity of our background color design tokens to simulate depth without introducing extra blur. +- **High contrast precedence:** If high-contrast mode is enabled, all glass effects must be automatically disabled to prioritize functional accessibility. +- **User controls and preferences:** Because glass mode introduces legibility risks, any product utilizing glass must also let users swap between default contrast and high contrast modes via a theme switcher or preferences menu. Products should also respect the OS-level `prefers-reduced-transparency` media query, disabling glass or replacing it with a solid high-opacity background to accommodate users appropriately. + +## Glass design tokens + +The following tokens are used together to create the glass effect. + +| Token | Value (in Felt theme) | Usage | +| --- | --- | --- | +| `-pf-t--global--background--color--glass--primary--default` | Light mode value: #FFFFFF (60% opacity)
Dark mode value: #292929 at 50% opacity | Base fill for glass containers. | +| `-pf-t--global--background--filter--glass--default` | Light mode value: #C7C7C7 (25% opacity)
Dark mode value: #C7C7C7 (15% opacity) | Overlay tint used to enhance blur visibility. | +| `-pf-t--global--border--color--glass--default` | Light mode value: #FFFFFF (60% opacity)
Dark mode value: #292929 (50% opacity) | Boundary highlight for glass surfaces. | +| `-pf-t--global--border--radius--glass--default` | #D6D6D6 with 16px radius | Default rounded border for glass element. | +| `-pf-t--global--background--color--sticky--default` | Light mode value: #FFFFFF (100% opacity)
Dark mode value: #292929 (100% opacity) | Solid background for sticky elements, like headers. | +| `-pf-t--global--box-shadow--medium` | #292929 (15% opacity) | Shadow that signifies elevation. | + +## Best practices + +To ensure a successful implementation, follow these best practices: +- Ensure all text meets a 4.5:1 (AA) contrast ratio. +- Ensure that high contrast mode overrides any use of glass to maintain accessibility requirements. +- Always verify glass components against both light and dark background variations to catch contrast failures early. \ No newline at end of file diff --git a/packages/documentation-site/patternfly-docs/content/foundations-and-styles/styles/theming/theming.md b/packages/documentation-site/patternfly-docs/content/foundations-and-styles/styles/theming/theming.md index 8baa660e31..791939817a 100644 --- a/packages/documentation-site/patternfly-docs/content/foundations-and-styles/styles/theming/theming.md +++ b/packages/documentation-site/patternfly-docs/content/foundations-and-styles/styles/theming/theming.md @@ -8,17 +8,44 @@ import '../../../components/components.css' import { Alert, AlertActionLink} from '@patternfly/react-core'; import ExternalLinkAltIcon from '@patternfly/react-icons/dist/esm/icons/external-link-alt-icon'; -A **theme** applies a specific visual style to all UI components in order to create a unique, cohesive, and purposeful look. The use of theming can provide more flexibility for user preferences, as well as different options for accessibility needs. +A **theme** applies specific visual styles to UI components to create a unique, cohesive, and purposeful look. Our theming architecture leverages [our design token system](/foundations-and-styles/design-tokens/overview) to flexibly support different brand identities, user preferences, and accessibility needs. -Theming is supported in PatternFly through [our design token system](/foundations-and-styles/design-tokens/overview), which was intentionally structured so that sets of tokens can be adjusted together to create alternate UI styles. By reassigning token values, the fonts, spacing, shadows, and borders in a UI can be changed together to create a theme. This system has enabled us to create multiple PatternFly themes, while also supporting the ability for you to create custom themes. +## Theming architecture -## PatternFly themes +We utilize a tiered theming architecture to consistently manage the appearance of UIs: +- **Theme:** Defines the foundational brand appearance, including core colors, border radii, iconography, and assets. +- **Color scheme:** Controls the brightness and palette shifts between light and dark environments. +- **Contrast mode:** Adjusts the style of surfaces and elements for specific aesthetic or accessibility needs. -The following themes are currently supported across PatternFly components and are designed to meet specific [WCAG accessibility standards](https://www.w3.org/WAI/standards-guidelines/wcag/). You can explore our different themes on our website by toggling your display preferences in our site's masthead dropdown. +## Themes + +We support 2 pre-built themes in PatternFly. While the visual identity of each theme differs, they share the same underlying interaction patterns and accessibility standards. + +### Default theme + +The Default theme creates the standard, open source PatternFly experience. It is characterized by blue branding, modern, square borders, and simple icons. + +### Felt theme + +The Felt theme is designed for products within the Red Hat portfolio, providing closer alignment with the [Red Hat Design System](https://ux.redhat.com/). It is characterized by red accent colors, smooth, rounded borderds, Red Hat icons, and [glass contrast mode](#glass). Core interactive elements, such as primary buttons, continue to use blue for usability. + +### Custom themes + +To branch off of our themes and create your own, you can identify the design tokens you'd like to adjust on our [all tokens page](/foundations-and-styles/design-tokens/all-design-tokens) and provide new values to use within your application. + +#### When to customize a theme + +There are a couple of instances when you might want to adjust an existing PatternFly theme: +- One-off adjustments, like changing a single button color, spacer, or font size, when intentional deviation is needed across your product. +- Application-wide adjustments, like changing all button colors and font sizes to adjust the overall brand identity of your product. + +## Color schemes ### Light mode -Generally, light mode is the default appearance of PatternFly. In this mode, dark text is presented on light backgrounds to meet a [text contrast ratio of at least 4.5:1](https://www.w3.org/WAI/WCAG22/quickref/?versions=2.1#contrast-minimum), while colors for other UI elements meet a [non-text contrast ratio of at least 3:1](https://www.w3.org/WAI/WCAG22/quickref/?versions=2.1#non-text-contrast). Some users might find it easier to read text on light screens, while others might simply prefer the appearance. +Light mode is the standard appearance for most web environments. + +Light mode places dark text on light backgrounds, while maintaining a [text contrast ratio of at least 4.5:1](https://www.w3.org/WAI/WCAG22/quickref/?versions=2.1#contrast-minimum) and a [non-text contrast ratio of at least 3:1](https://www.w3.org/WAI/WCAG22/quickref/?versions=2.1#non-text-contrast). Some users might find light screens easier to read, while others might simply prefer the appearance.
![A collage of multiple light-themed PatternFly components, like a calendar, alert, and menu. The components have white backgrounds and black text.](./img/components-light.svg) @@ -26,68 +53,59 @@ Generally, light mode is the default appearance of PatternFly. In this mode, dar ### Dark mode -In dark mode, light text is presented on dark backgrounds backgrounds, and our color palette adapts to maintain a [text contrast ratio of at least 4.5:1](https://www.w3.org/WAI/WCAG22/quickref/?versions=2.1#contrast-minimum) and [non-text contrast ratio of at least 3:1](https://www.w3.org/WAI/WCAG22/quickref/?versions=2.1#non-text-contrast). Some users might prefer dark mode for aesthetics, while others find it to be easier on the eyes and less straining for those with light sensitivities. +Dark mode adapts color palettes for light-sensitive users or low-light environments. It presents light text on dark backgrounds backgrounds while maintaining the same accessibility ratios as light mode. Some users might prefer dark mode for aesthetics, while others find it to be easier on the eyes and less straining for those with light sensitivities. -For development guidance, refer to the [dark theme handbook](/foundations-and-styles/theming/dark-theme-handbook). +For implementation guidance, refer to the [dark theme handbook](/foundations-and-styles/theming/dark-theme-handbook).
![A collage of multiple dark-themed PatternFly components, like a calendar, alert, and menu. The components have dark gray backgrounds and white text.](./img/components-dark.svg)
-### High contrast mode - - -

High contrast mode is still under development and will continue to evolve and be enabled for charts and extensions. This beta allows you to preview our progress.

-
+## Contrast modes -High contrast mode adjusts our default colors to meet an [enhanced contrast ratio of at least 7:1](https://www.w3.org/WAI/WCAG21/Understanding/contrast-enhanced.html), making it more suitable for users who require higher contrast between UI elements. By using wider border strokes and adjusted fill colors, high contrast mode creates more visual distinction and clarity between interactive elements. +Contrast modes adjust the surface treatment of UI elements across both color schemes. They are mutually exclusive and can't be applied simultaneously. -In high contrast mode, distinct borders are also added to components to ensure that their boundaries are clearly defined without requiring users to rely on subtle background colors as a visual cue. +### Default contrast -For development guidance, refer to the [high contrast handbook](/foundations-and-styles/theming/high-contrast-handbook). +Default contrast mode is used in the Default theme and doesn't include special enhancements to increase contrast in UI elements. This mode doesn't need to be enabled and simply refers to the standard color palette used to achieve level AA accessibility, with contrast ratios of 4.5:1 for normal text, 3:1 for large text, and 3:1 for graphics and other UI components. -
-![A collage of multiple PatternFly components, like a calendar, alert, and menu. The top half of the image has components on a white background with black text and the bottom half of the image has dark components on a black background with light text. All components have high contrast, with borders and noticeable colors.](./img/components-hc.svg) -
- -## Custom themes +### High contrast -To branch off of our themes and create your own, you can identify the design tokens you'd like to adjust on our [all tokens page](/foundations-and-styles/design-tokens/all-design-tokens) and provide new values to use within your application. +High contrast mode is focused on improving accessibility for users who require more clarity and higher contrast between UI elements. Turned on by user preference, high contrast mode adjusts border strokes and colors to meet an [enhanced contrast ratio of at least 7:1](https://www.w3.org/WAI/WCAG21/Understanding/contrast-enhanced.html). -### When to customize a theme +**Note:** Activating high contrast mode will override and disable glass mode to ensure all boundaries and text meet strict accessibility requirements. -There are a couple of instances when you might want to adjust an existing PatternFly theme: -- One-off adjustments, like changing a single button color, spacer, or font size, when intentional deviation is needed across your product. -- Application-wide adjustments, like changing all button colors and font sizes to adjust the overall brand identity of your product. +For implementation guidance, refer to the [high contrast handbook](/foundations-and-styles/theming/high-contrast-handbook). -## Using themes in Figma - -Our Figma libraries fully support theming. Designers can create a single design and then swap between our themes using the "Apply Variable Mode" toggles in the "Appearance" section of the component properties panel. This makes it easy to visually test and validate designs across all supported themes. - -The standard light PatternFly theme will be applied to components by default. If you want your mockups to use our dark or high contrast themes, you will need to adjust the following settings in Figma. +
+![A collage of multiple PatternFly components, like a calendar, alert, and menu. The top half of the image has components on a white background with black text and the bottom half of the image has dark components on a black background with light text. All components have high contrast, with borders and noticeable colors.](./img/components-hc.svg) +
-### Dark mode +### Glass -To swap your components to our standard dark mode, change the Semantic Color Tokens variable mode to be "Dark": +Glass mode introduces transparency and depth to the UI, creating a layered visual effect. It is enabled in the Felt theme by default, but can also be manually enabled in the Default theme. -
-![Figma settings menu to select different token variables.](./img/figma-dark-mode.svg) -
+When glass is enabled, the following changes will apply: +- **Transparency:** Container backgrounds will become more transparent, allowing the content below to subtly show through. +- **Background image:** A pre-approved background image will fill the page body. Product teams must work with the Brand team ensure these images maintain accessibility compliance behind UI elements. +- **Layout changes:** Layout variations, including the banded masthead and floating side navigation. -### High contrast mode +For more details, including implementation guidance, refer to the [glass mode handbook](/foundations-and-styles/theming/glass-mode-handbook). -To swap your components to our high contrast mode, change the Semantic Dimension Tokens variable mode to be "High Contrast" and choose either "Light - High Contrast" or "Dark - High Contrast" for the Semantic Color Tokens variable mode: +## Feature compatibility -
-![Figma settings menu to select different token variables.](./img/figma-hc-mode.svg) -
+The following table outlines the availability and compatibility of PatternFly features across themes. -### Chart themes +| Feature | Default theme | Felt theme | +| --- | --- | --- | +| Accent color | Blue | Red | +| Interactive element colors | Blue | Blue | +| Border radius shape | Square | Pill | +| Default contrast mode | Standard | Glass | +| Background image | Optional (Manual) | Required (with glass mode) | +| Branded icons | Optional (Manual) | Default +| High contrast support | Yes | Yes | -Our charts use a unique token collection, so you will need to adjust chart variable modes separately from components in order to swap themes. To change the variable mode for charts, follow the same steps previously outlined for component theme adjustments. ## Best practices @@ -102,4 +120,32 @@ To ensure your application is robust, maintainable, and adaptable across differe - **Prioritize semantic tokens:** Always use the most relevant semantic token for your use case to ensure the element's purpose is clear and that it receives the correct styling in any theme. If no semantic token exists, you can fall back to a base token. - **Never use a palette token**: Do not use palette tokens (like `--pf-t--color--blue--20`) directly in your code, as the value is not guaranteed to be consistent across themes. - **Use scalable icons:** For icons, use vector images (SVG) or icon fonts instead of raster or bitmap images (PNG, JPEG, GIF, BMP, and so on). This allows you to control their color with CSS `fill` and `color` properties. By assigning a design token to these properties, your icons will automatically change color to match the active theme. - - If you must use static images, you might need to hide and show different image files based presence of a theme-specific class (like `pf-v6-theme-dark`). \ No newline at end of file + - If you must use static images, you might need to hide and show different image files based presence of a theme-specific class (like `pf-v6-theme-dark`). + +## Theming in Figma + +Our Figma libraries fully support theming. Designers can create a single design and then swap between our themes using the "Apply Variable Mode" toggles in the "Appearance" section of the component properties panel. This makes it easy to visually test and validate designs across all supported themes. + +The standard light PatternFly theme will be applied to components by default. If you want your mockups to use our dark or high contrast themes, you will need to adjust the following settings in Figma. + +**Note:** Our charts use a unique token collection, so you will need to adjust chart variable modes separately from components in order to swap themes. To change the variable mode for charts, follow the same steps outlined for component theme adjustments. + +### Swapping themes + +To swap between the Default and Felt themes, adjust the theme variable mode. The Felt mode will automatically apply the red accents, pill shapes, and glass treatment. + +### Swapping color schemes + +To swap your components to our standard dark mode, change the Semantic Color Tokens variable mode to be "Dark": + +
+![Figma settings menu to select different token variables.](./img/figma-dark-mode.svg) +
+ +### Swapping contrast modes + +To swap your components to our high contrast mode, change the Semantic Dimension Tokens variable mode to be "High Contrast" and choose either "Light - High Contrast" or "Dark - High Contrast" for the Semantic Color Tokens variable mode: + +
+![Figma settings menu to select different token variables.](./img/figma-hc-mode.svg) +
\ No newline at end of file