Disclosure
A disclosure allows the user to show and hide additional content.
Anatomy
- Summary Button - a control that opens or closes the disclosure and conveys to the user what is contained in the disclosure body.
- Summary Marker - an icon that indicates that the disclosure can be opened or closed.
- When displayed before the label, the marker should point to the right when closed and down when open.
- When displayed after the label, the marker should point down when closed and up when open.
- Body - the disclosed contents, as summarized by the summary button.
Usage
Use a disclosure when you want to help the user manage their attention on the page. Disclosures allow the user to skip over secondary content or features by not expanding the disclosure, while still giving them the option to delve deeper should they choose to expand it. The disclosure is named for the principle of progressive disclosure.
- A disclosure has two states: collapsed and expanded. A disclosure is collapsed by default.
- A disclosure should include an icon that conveys that it can be activated for more information.
- A disclosure’s label should clearly and succinctly describe its hidden content, so that the user can choose to expand it.
- When a disclosure has focus, Enter and Space activate the disclosure and toggle the visibility of content.
- All focusable elements inside a disclosure are included in the tab order, if the disclosure is expanded.
React API
import { Disclosure } from '@wwnds/react';
Disclosure
<Disclosure panel summary="Default disclosure"> Lorem ipsum dolor sit amet consectetur adipisicing elit. </Disclosure>
Name | Description | Type |
---|---|---|
summary (required) | The content for the summary element generated by the disclosure component. | ReactNode |
marker | The marker icon that indicates the disclosure's current state. Similar to the
CSS | IconVariant | SVGIcon | ((panel?: boolean) => IconVariant | SVGIcon | null) | null | undefined |
markerPosition | The position of the marker. right when panel={true} and left otherwise. | "right" | "left" | ((panel?: boolean) => "right" | "left" | null) | null | undefined |
markerTransform | How the marker should move when it opens. Default is "rotate-90" . | "none" | "rotate-90" | "flip-3d" |
isOpen | Used to set the initial open state or fully control it. | boolean |
panel | Indicates that the disclosure should be in "panel" mode, which has a few effects:
| boolean |
reducedMotion | Indicates that animations should be disabled. | boolean |
baseName | The base className according to BEM conventions. | string |
summaryClass | The className that will be applied to the <summary> . | string |
contentsOuterClass | The className for the outer contents <div> . | string |
contentsInnerClass | The className that will be applied to the inner contents <div> . | string |
markerClass | The | string |
onCloseStart | Lifecycle method that is triggered when the disclosure begins to close.
Returning | LifecycleCallback |
onCloseCancel | Lifecycle method that is triggered when the user clicks on the disclosure
as it's closing. Returning | LifecycleCallback |
onCloseEnd | Lifecycle method that is triggered when the disclosure has finished closing. | LifecycleCallback |
onOpenStart | Lifecycle method that is triggered when the disclosure begins to open.
Returning | LifecycleCallback |
onOpenCancel | Lifecycle method that is triggered when the user clicks on the disclosure
as it's opening. Returning | LifecycleCallback |
onOpenEnd | Lifecycle method that is triggered when the disclosure has finished opening. | LifecycleCallback |