Context Selector

Overview

The Context Selector is used when the data/resources shown in the UI are dependent on context. It is useful when the UI cannot show data for multiple contexts simultaneously, or when it makes sense not to. Different contexts within a product should share the same navigation, but will differ in the data shown. Examples of contexts could include concepts such as region, project, or organization, but the specific notion of context is defined by the individual product.

Context Selector Left Side

The context selector should appear as a dropdown in the Masthead, next to the application branding.

This pattern should NOT be used:

  • When there is a need to select more than one context within a single layer of context (multiselect).
  • As a shortcut for other navigation items.
  • To navigate to a different “product area” with different navigation options/features. For that use case, consider the Launcher.

Context Selector

Context Selector Search

  1. If the context names are user-generated, a label should be included above the selector.
  2. If there is a search bar, it should be at the very top of the menu.
  3. If there are many items (i.e. more than 12), the dropdown should scroll and a search field should be added to filter the list as the user types.

Responsive Behavior

Context Selector Mobile

  • Because the context identifies what is in the UI, the Context Selector should remain visible at smaller viewports.
  • Product branding should be dropped in favor of keeping the context visible.
  • If the product branding served as navigation, that navigation item should be added to the hamburger menu.

Truncation

Context names may need to be truncated if the names are very long, or if horizontal space is tight. Names should be truncated in a way that makes sense for the product or application. See PatternFly’s guidelines on truncation.

Code icon

PatternFly Core Example Not Available

There is no PatternFly-Core code available for this pattern at this time. Links to the JS framework implementations can be seen above.

Visit the Contributing to PatternFly documentation to learn how to contribute the code.