# 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 a form control (`Checkbox` or `Switch`) component. The content blocks can be specified as children inside a structure component (`View`, `InlineLayout`, `BlockStack`, `Grid`, etc.).

The library automatically applies the [WAI-ARIA Accordion pattern](https://www.w3.org/WAI/ARIA/apg/patterns/accordion/) to both the activator and the toggled content.
### Basic Disclosure

```tsx
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>
  );
}

```

```js
import {
  extension,
  Button,
  View,
  Disclosure,
} from '@shopify/ui-extensions/checkout';

export default extension('purchase.checkout.block.render', (root) => {
  const disclosure = root.createComponent(Disclosure, {}, [
    root.createComponent(Button, {toggles: 'one'}, 'Toggle'),
    root.createComponent(
      View,
      {border: 'base', padding: 'base', id: 'one'},
      'Content',
    ),
  ]);

  root.appendChild(disclosure);
});

```


## DisclosureProps

### DisclosureProps

### defaultOpen
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 `id`s
### onToggle
Callback fired when the open state of the disclosure changes.
### open
For controlled disclosure components, the open state. The `open` prop should be used along with `onToggle` to create a controlled disclosure component.
### transition
Set to 'none' to disable the default transition animation.
### MaybeResponsiveConditionalStyle
A type that represents a value that can be a conditional style. The conditions are based on the viewport size. We highly recommend using the `Style` helper which simplifies the creation of conditional styles.

To learn more check out the [conditional styles](/api/checkout-ui-extensions/components/utilities/stylehelper) documentation.
T | ConditionalStyle<T, ViewportSizeCondition>
### ConditionalStyle

### conditionals
An array of conditional values.
### default
The default value applied when none of the conditional values specified in `conditionals` are met.
### ConditionalValue

### conditions
The conditions that must be met for the value to be applied. At least one condition must be specified.
### value
The value that will be applied if the conditions are met.
### ViewportSizeCondition

### viewportInlineSize

### DisclosureOpen

boolean | string | string[]
## Examples
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 a form control (`Checkbox` or `Switch`) component. The content blocks can be specified as children inside a structure component (`View`, `InlineLayout`, `BlockStack`, `Grid`, etc.).

The library automatically applies the [WAI-ARIA Accordion pattern](https://www.w3.org/WAI/ARIA/apg/patterns/accordion/) to both the activator and the toggled content.
### 
Use the Disclosure component to simplify the user experience and reveal interfaces only when the customer requests it. It also demonstrates how a combination of inline and block layout components can improve the readability of information. By employing these strategies, users can easily scan and comprehend the content, making for a better user experience overall.
### Strategies for simplifying layout and aligning content using Disclosure and Inline/Block Layout components.

```jsx
import {
  reactExtension,
  View,
  Image,
  Icon,
  Pressable,
  Disclosure,
  InlineLayout,
  BlockStack,
  Text,
  Form,
  TextField,
  Button,
  Divider,
  InlineStack,
} from '@shopify/ui-extensions-react/checkout';

export default reactExtension(
  'purchase.checkout.block.render',
  () =&gt; &lt;DisclosureAndAlignment /&gt;,
);

export const DisclosureAndAlignment = () =&gt; {
  const openIds = ['one'];
  return (
    &lt;View
      maxInlineSize={400}
      cornerRadius="large"
      border="base"
    &gt;
      &lt;BlockStack spacing="none"&gt;
        &lt;Disclosure
          defaultOpen="one"
          onToggle={(open) =&gt;
            console.log('onToggle event', open)
          }
        &gt;
          &lt;Pressable toggles="one" padding="base"&gt;
            &lt;InlineLayout
              blockAlignment="center"
              spacing="base"
              columns={['auto', 'fill', 'auto']}
            &gt;
              &lt;Icon
                source="gift"
                appearance="subdued"
              /&gt;
              Gift message
              &lt;Icon
                source={
                  openIds.includes('one')
                    ? 'chevronUp'
                    : 'chevronDown'
                }
                appearance="subdued"
              /&gt;
            &lt;/InlineLayout&gt;
          &lt;/Pressable&gt;
          &lt;View
            id="one"
            padding={[
              'none',
              'base',
              'base',
              'base',
            ]}
          &gt;
            &lt;Form
              onSubmit={() =&gt;
                console.log('onSubmit event')
              }
            &gt;
              &lt;BlockStack&gt;
                &lt;InlineLayout
                  columns={['fill', 'fill']}
                  spacing="base"
                &gt;
                  &lt;TextField
                    label="From"
                    name="from0"
                    id="from0"
                  /&gt;
                  &lt;TextField
                    label="To"
                    name="to0"
                    id="to0"
                  /&gt;
                &lt;/InlineLayout&gt;
                &lt;TextField
                  label="Message"
                  name="message0"
                  id="message0"
                /&gt;
                &lt;View&gt;
                  &lt;Button
                    accessibilityRole="submit"
                    kind="secondary"
                  &gt;
                    Save
                  &lt;/Button&gt;
                &lt;/View&gt;
              &lt;/BlockStack&gt;
            &lt;/Form&gt;
          &lt;/View&gt;
        &lt;/Disclosure&gt;
        &lt;Divider /&gt;
        &lt;InlineLayout
          blockAlignment="baseline"
          spacing="base"
          columns={['auto', 'fill', 'auto']}
          padding="base"
        &gt;
          &lt;Icon
            source="profile"
            appearance="subdued"
          /&gt;
          &lt;BlockStack spacing="none"&gt;
            &lt;InlineStack blockAlignment="center"&gt;
              &lt;Text&gt;Verify with&lt;/Text&gt;
              &lt;Image source="https://via.placeholder.com/50x15" /&gt;
            &lt;/InlineStack&gt;
            &lt;Text
              appearance="subdued"
              size="small"
            &gt;
              15% savings for students and
              military
            &lt;/Text&gt;
          &lt;/BlockStack&gt;
          &lt;Pressable to="https://www.shopify.com"&gt;
            &lt;Icon
              source="external"
              appearance="subdued"
            /&gt;
          &lt;/Pressable&gt;
        &lt;/InlineLayout&gt;
      &lt;/BlockStack&gt;
    &lt;/View&gt;
  );
};

```

```js
import {
  extension,
  BlockStack,
  View,
  InlineLayout,
  InlineStack,
  Image,
  Pressable,
  Icon,
  Text,
  TextField,
  Form,
  Button,
  Disclosure,
  Divider,
} from '@shopify/ui-extensions/checkout';

export default extension(
  'purchase.checkout.block.render',
  (root) =&gt; {
    const openIds = ['one'];

    const pressable = root.createComponent(
      Pressable,
      {
        toggles: 'one',
        padding: 'base',
      },
      [
        root.createComponent(
          InlineLayout,
          {
            blockAlignment: 'center',
            spacing: 'base',
            columns: ['auto', 'fill', 'auto'],
          },
          [
            root.createComponent(Icon, {
              source: 'gift',
              appearance: 'subdued',
            }),
            'Gift message',
            root.createComponent(Icon, {
              source: openIds.includes('one')
                ? 'chevronUp'
                : 'chevronDown',
              size: 'small',
            }),
          ],
        ),
      ],
    );

    const disclosureView = root.createComponent(
      View,
      {
        id: 'one',
        padding: ['none', 'base', 'base', 'base'],
      },
      [
        root.createComponent(
          Form,
          {
            onSubmit: () =&gt;
              console.log('onSubmit event'),
          },
          [
            root.createComponent(BlockStack, {}, [
              root.createComponent(
                InlineLayout,
                {
                  columns: ['fill', 'fill'],
                  spacing: 'base',
                },
                [
                  root.createComponent(
                    TextField,
                    {
                      label: 'From',
                      name: 'from0',
                      id: 'from0',
                    },
                  ),
                  root.createComponent(
                    TextField,
                    {
                      label: 'To',
                      name: 'to0',
                      id: 'to0',
                    },
                  ),
                ],
              ),
              root.createComponent(TextField, {
                label: 'Message',
                name: 'message0',
                id: 'message0',
              }),
              root.createComponent(View, {}, [
                root.createComponent(
                  Button,
                  {
                    accessibilityRole: 'submit',
                    kind: 'secondary',
                  },
                  'Save',
                ),
              ]),
            ]),
          ],
        ),
      ],
    );

    const disclosure = root.createComponent(
      Disclosure,
      {
        defaultOpen: 'one',
        onToggle: (open) =&gt;
          console.log('onToggle event', open),
      },
      [pressable, disclosureView],
    );

    const inlineLayout = root.createComponent(
      InlineLayout,
      {
        blockAlignment: 'baseline',
        spacing: 'base',
        columns: ['auto', 'fill', 'auto'],
        padding: 'base',
      },
      [
        root.createComponent(Icon, {
          source: 'profile',
          appearance: 'subdued',
        }),
        root.createComponent(
          BlockStack,
          {
            spacing: 'none',
          },
          [
            root.createComponent(
              InlineStack,
              {
                blockAlignment: 'center',
              },
              [
                root.createComponent(
                  Text,
                  {},
                  'Verify with',
                ),
                root.createComponent(Image, {
                  source:
                    'https://via.placeholder.com/50x15',
                }),
              ],
            ),
            root.createComponent(
              Text,
              {
                appearance: 'subdued',
                size: 'small',
              },
              '15% savings for students and military',
            ),
          ],
        ),
        root.createComponent(
          Pressable,
          {
            to: 'https://www.shopify.com',
          },
          [
            root.createComponent(Icon, {
              source: 'external',
              appearance: 'subdued',
            }),
          ],
        ),
      ],
    );
    const view = root.createComponent(
      View,
      {
        maxInlineSize: 400,
        cornerRadius: 'large',
        border: 'base',
      },
      [
        root.createComponent(
          BlockStack,
          {
            spacing: 'none',
          },
          [
            disclosure,
            root.createComponent(Divider),
            inlineLayout,
          ],
        ),
      ],
    );

    root.appendChild(view);
  },
);

```