A Module is a container that holds content about one subject. Its contents can be visible at all times, or expand and collapse as individual modules or a group of modules.

Static Module Props

Static Module subcomponent props
Name
Type
Default
Required
string
-

Unique id to identify this Module

string
-

Add a badge displayed after the title. Will not be displayed if title is not provided. Not to be used with icon or iconButton. Be sure to localize the text.

React.Node
-

Content to display underneath Module title

string
-

Name of icon to display in front of title. Will not be displayed if title is not provided. Not to be used with badgeText or iconButton.

string
-

Label to provide information about the icon used for screen readers. Can be used in two scenarios: to describe the error icon that appears when type is error, and to describe the provided icon prop when type is info. Be sure to localize the label.

React.Element<IconButton>
-

IconButton element to be placed after the title for a supplemental Call To Action (CTA). Will not be displayed if title is not provided. Not to be used with badgeText or icon.

string
-

Title of this Module. Be sure to localize the text.

"info" | "error"
"info"

If set to error, displays error icon and changes title to red text. Be sure to provide an iconAccessibilityLabel when set to error.

Expandable Module Props

Expandable Module subcomponent props
Name
Type
Default
string
-

Label used to communicate to screen readers which module will be collapsed when interacting with the title button. Should be something clear, like "Collapse Security Policies Module". Be sure to localize the label.

string
-

Label used to communicate to screen readers which module will be expanded when interacting with the title button. Should be something clear, like "Expand Security Policies Module". Be sure to localize the label.

Required
string
-

Unique id to identify this Module

Required
Array<{| badgeText?: string, children: ?React.Node, icon?: $Keys<typeof icons>, iconAccessibilityLabel?: string, iconButton?: Element<typeof IconButton>, summary?: Array<string>, title: string, type?: "info" | "error" |}>
-

Array of modules displayed in a stack. Only one item can be expanded at a time.

expandedIndex
?number
-

The 0-based index indicating the item that should currently be expanded. This must be updated via onExpandedChange to ensure the correct item is expanded.

onExpandedChange
(?number) => void
-

Callback executed whenever any module item is expanded or collapsed. It receives the index of the currently expanded module, or null if none are expanded.

Usage guidelines

When to Use
  • Grouping and organizing content to keep the page clean and digestible.
  • Displaying additional related content about a particular subject.
  • Enabling users to reveal or hide additional content as necessary (with Expandable variant).
When Not to Use
  • In a layout that conveys a clear sense of information hierarchy. Use SegmentedControl instead.
  • When long content can’t be displayed all at once, and scrolling is necessary.
  • When there is insufficient content to condense, as collapsing can increase cognitive load and interaction cost. Consider the static variant of Module.
  • When the content is crucial to read in full. Consider the static variant instead.

Static

A Module is a container that can hold any content, and can optionally have a title that describes the content inside. The default, static Module is used to display information that should always be visible.

This is example content.
Title
This is example content.

Static - Icon

An Icon can be provided to be placed before the title.

It is recommended that icons be used sparingly to convey additional information, and instead should simply reinforce information in the title. Be sure to provide an iconAccessibilityLabel.

Title
This is example content.

Static - IconButton

An IconButton can be provided to be placed after the title for a supplemental Call To Action (CTA).

Title
This is example content.

Static - Badge

Badge text can be provided, which will be displayed after the title. Note that if no title text is provided, the badge will not be displayed.

Title
Try it out!
This is example content.

Static - Error

When using type as "error", be sure to provide an iconAccessibilityLabel.

Personal Info
This is example content.
This field can't be blank!

Expandable

Modules can also allow for expanding and collapsing content. The title is required and always present. The collapsed state shows optional summary content, while the expanded state shows any content desired.

Expandable - Group

Multiple expandable items can be stacked together into a Module group. However, only one Module will be expanded at any time.



Expandable - Icon, Badge and IconButton

An Icon can be provided to be placed before the title.
It is recommended that icons be used sparingly to convey additional information, and instead should simply reinforce information in the title. Be sure to provide an iconAccessibilityLabel.

Badge text can also be provided, which will be displayed after the title.

An IconButton can be provided to be placed after the title for a supplemental Call To Action (CTA).



Expandable - Error

When using type as "error", be sure to provide an iconAccessibilityLabel.

Example with external control

Step 1

Step 2