Skip to main content

Disclosure

Disclosure is an optionally controlled component used to put long sections of information under content blocks that users can expand or collapse by pressing an activator. The activator can be specified as children using an action component (Button, Link or Pressable) or Checkbox component. The content blocks can be specified as children inside a structure component (View, InlineLayout, BlockStack, Grid, etc.).

The library takes care of applying the WAI-ARIA Accordion pattern automatically for the activator and the toggled content.

Anchor to defaultOpen
defaultOpen
< | undefined>

For uncontrolled disclosure components, the default open state on the initial render.

It's possible to specify a boolean value, a string value, or an array of string values:

  • true will expand all content
  • false will collapse all content
  • string will expand the content with the matching id
  • string[] will expand the content with the matching ids

For controlled disclosure components, the open state. The open prop should be used along with onToggle to create a controlled disclosure component.

Anchor to onToggle
onToggle
(open: string[]) => void

Callback fired when the open state of the disclosure changes.

Anchor to transition
transition
"none"

Set to 'none' to disable the default transition animation.

Examples
import {
reactExtension,
Disclosure,
Button,
View,
} from '@shopify/ui-extensions-react/checkout';

export default reactExtension(
'purchase.checkout.block.render',
() => <Extension />,
);

function Extension() {
return (
<Disclosure>
<Button toggles="one">Toggle</Button>
<View id="one">Content</View>
</Disclosure>
);
}

Preview

  • Disclosures should be initiated by the buyer.

  • Use disclosures to hide content until they are relevant to the buyer.

  • Avoid hiding critical information that buyers need to complete their checkout.

  • Keep content inside disclosures concise.

  • Avoid nesting of disclosures.

  • Keep the activator and the content it toggles in close proximity to each other.

Was this page helpful?