Replies: 1 comment 2 replies
-
I'd love to take a stab at adding this to zag |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
🚀 Feature request
Add a new machine for the WAI-ARIA disclosure pattern (see https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/)
This is also available in Chakra (https://chakra-ui.com/docs/hooks/use-disclosure) and Ariakit has some prior art (https://ariakit.org/components/disclosure).
Note this is not the same as Popover or Menu, because there is no concept of a positioner. It also isn't the same as an accodion, because there is no set of content in a disclosure and no concept that the trigger is a heading for the disclosure.
🧱 Problem Statement / Justification
This is a common design pattern that has many a11y concerns associated with it. It would be a valuable component of zag and could be composed as part of other components as well.
✅ Proposed solution or API
The API should have:
getTriggerProps
for the element that shows and hides the contentgetContentProps
for the element that contains all the content that is shown or hiddenThe machine should be passed:
open
(optional) whether the content should begin in the open state (default isfalse
)disabled
(optional) whether the control should be disabled (default isfalse
)The following methods should be available:
isOpen: boolean
whether the disclosure content is openisDisabled: boolean
whether the disclosure control is disabledisFocused(): boolean
whether the disclosure control is focusedsetOpen(open: boolean): void
Function to set the open state of the disclosuretoggleOpen(): void
Function to toggle the open state of the disclosure↩️ Alternatives
📝 Additional Information
Beta Was this translation helpful? Give feedback.
All reactions