FAQ

Use the FAQ component to display content in a Q&A format.

import {FAQ, FAQGroup} from '@primer/react-brand'

Examples

Default

Loading

Grouped FAQs

Use FAQGroup to display multiple FAQ components together.

Use tabAttributes to add arbitrary attributes to the tabs. This can be useful for tracking analytics or adding custom attributes.

Loading

Rendering with dynamic data

Loading

Toggle color customization

FAQ.Question toggle colors can be adjusted using one of the following approaches:

  1. Override the global --brand-color-accent-primary CSS variable (recommended).
  2. Use the toggleColor prop on FAQ.Question.

Available options for toggleColor are:

'default', 'blue', 'coral', 'green', 'gray', 'indigo', 'lemon', 'lime', 'orange', 'pink', 'purple', 'red', 'teal', 'yellow', 'blue-purple', 'green-blue', 'pink-blue', 'purple-red', 'red-orange'

See Storybook for all color options.

Loading

Component props

FAQ Required

NameTypeDefaultDescription
classNamestringSets a custom class
idstringSets a custom id
refReact.RefObjectForward a Ref to the underlying DOM node
children'FAQ.Heading', 'FAQ.Subheading', 'FAQ.Item'
Root element for the FAQ component.

FAQ.Heading Required

NameTypeDefaultDescription
align'start', 'center'
'center'Heading text alignment
childrenstringHeading text
classNamestringHeading custom class
idstringSets a custom id
refReact.RefObjectForward a Ref to the underlying DOM node
size'medium', 'large'
'medium'Heading text size
as'h1', 'h2', 'h3', 'h4', 'h5', 'h6'
Applies the underlying HTML element
toggleColor'default', 'blue', 'coral', 'green', 'gray', 'indigo', 'lemon', 'lime', 'orange', 'pink', 'purple', 'red', 'teal', 'yellow', 'blue-purple', 'green-blue', 'pink-blue', 'purple-red', 'red-orange'
Sets the accordion toggle color

FAQ.Subheading

NameTypeDefaultDescription
childrenstringSub-heading text
classNamestringSub-heading custom class
idstringSets a custom id
as'h2', 'h3', 'h4', 'h5', 'h6'
'h3'Applies the underlying HTML element
refReact.RefObjectForward a Ref to the underlying DOM node

FAQ.Item

NameTypeDefaultDescription
openbooleanfalseSets answer visibility
classNamestringSets a custom class
children'FAQ.Question', 'FAQ.Answer'
FAQ question and answer pair
idstringSets a custom id
refReact.RefObjectForward a Ref to the underlying DOM node

FAQ.Question

NameTypeDefaultDescription
classNamestringSets a custom class on the root element
childrenstringQuestion text
idstringSets a custom id
as'h2', 'h3', 'h4', 'h5', 'h6'
'h4'Applies the underlying HTML element
refReact.RefObjectForward a Ref to the underlying DOM node

FAQ.Answer

NameTypeDefaultDescription
classNamestringSets a custom class on the root element
childrenReactElement<p> or <Text> components are recommended
idstringSets a custom id
refReact.RefObjectForward a Ref to the underlying DOM node

FAQGroup

NameTypeDefaultDescription
classNamestringSets a custom class
idstringSets a custom id
refReact.RefObjectForward a Ref to the underlying DOM node
children'FAQ', 'FAQGroup.Heading'
Root element for the FAQGroup component.
tabAttributes(children: ReactElement, index: number) => Record<string, unknown>Spreads the returned attributes onto the tab that’s rendered by the FAQGroup.

FAQGroup.Heading

NameTypeDefaultDescription
as'h1', 'h2', 'h3', 'h4', 'h5', 'h6'
Applies the underlying HTML element

Forwards all the props from the Heading component, including size, and weight.