Skip to content
Paste
UX Platform
Change the site theme
GitHub

Disclosure

The Disclosure is used to create accessible, hierarchical, and collapsible structure to your pages.

Status
beta
Version
5.0.2
Sources
Import from
@twilio-paste/core/disclosure — or — @twilio-paste/disclosure

Guidelines#

About Disclosure#

The Disclosure is used to create accessible, hierarchical, and collapsible structure to your pages. It uses the Paste Heading component to create consistency across pages and content hierarchy.

Accessibility#

You must not nest focusable or actionable elements inside the DisclosureHeading. Nested actionable elements are difficult to discover for users of assistive technology as their existence is often not announced.

Examples#

Default Disclosure#

The default variant of a Disclosure is a composition of the Paste Heading and a chevron button icon as the "trigger" for the disclosure. This trigger controls the appearance of content that is below it.

The DisclosureHeading takes the same props as the Heading component so you can control the semantic heading level and it's visual appearance through variants.

Contained Disclosure#

The contained variant of the Disclosure takes the default composition and wraps it in the Paste Card component. In this instance we do not expose the props used by Card, but all previously mentioned Disclosure props behave in the same way as the default variant.

Controlling initial state#

You can control the initial state of the disclosure to be expanded or collapsed by setting the visible prop.

Disclosure Heading

Content

Using state hooks#

🚨 ATTENTION!! 🚨

If you decided to use state hooks, the Paste team is NOT responsible for debugging any issues in your application.

The state prop allows you to hook into, and keep in sync the state of the Disclosure and the state of your application.

This will allow you to set initial state and merge the returned state from the hook with the application state, and keep it in sync with user interactions.

You could use this if you need to wait for a response from an API before opening the Disclosure content. In the example below, we're simulating the response time by adding a delay.

States#

Disabled#

Each Disclosure can be disabled by setting the disabled prop on the DisclosureHeading

Disclosure Heading

Content

Composition notes#

Both DisclosureHeading and DisclosureContent accept any child component, leaving flexibility to create a large number of custom compositions for your product needs.

The only thing you must not do is place a focusable element inside the DisclosureHeading, see accessibility notes.

Disclosure Heading - deployment issueError

Content

Anatomy#

Disclosure#

Contained#

Contained Disclosure variants share the Paste Card anatomy.

DisclosureHeading#

Same Anatomy as Heading, plus:

PropertyDefault tokenModifiable?
background-colorcolor-background-bodyNo
border-radiusborder-radius-20No
border-bottom-left-radiusDefault: border-radius-20, Contained: border-radius-0No
border-bottom-right-radiusDefault: border-radius-20, Contained: border-radius-0No
paddingspace-30No

Expanded#

PropertyDefault tokenModifiable?
background-colorcolor-backgroundNo

Hover#

PropertyDefault tokenModifiable?
background-colorcolor-background-darkNo

Focus#

PropertyDefault tokenModifiable?
box-shadowshadow-focusNo

DisclosureContent#

PropertyDefault tokenModifiable?
paddingspace-50No

Usage Guide#

API#

Installation#

yarn add @twilio-paste/disclosure - or - yarn add @twilio-paste/core

Usage#

import {Disclosure, DisclosureHeading, DisclosureContent} from '@twilio-paste/disclosure';
const PopoverExample: React.FC = () => {
return (
<Disclosure>
<DisclosureHeading as="h2" variant="heading20">
Disclosure Heading
</DisclosureHeading>
<DisclosureContent>Disclosure content</DisclosureContent>
</Disclosure>
);
};

Props#

Disclosure Props#

All the regular HTML attributes (role, aria-*, type, and so on) including the following custom props:

baseId prop

ID that will serve as a base for all the items IDs.

visible prop

Whether it's visible or not.

variant prop

Changes the styling on the component based on the variant selected.

DisclosureHeading Props#

All the regular HTML attributes (role, aria-*, type, and so on).

All Heading props.

Also including the following custom props:

disabled prop

Same as the HTML attribute.

focusable prop

When an element is disabled, it may still be focusable. It works similarly to readOnly on form elements. In this case, only aria-disabled will be set.

DisclosureContent Props#

All the regular HTML attributes (role, aria-*, type, and so on) including the following custom props:


Black lives matter.