How to use this component
Use an interactive element that can trigger a custom event handler provided by the :toggle
block (is passed via hash
by Ember). This element is usually usually a button, or a component that renders a button (for accessibility reasons).
<Hds::Disclosure>
<:toggle as |t|>
<button type="button" >Click me</button>
</:toggle>
<:content>
your content here
</:content>
</Hds::Disclosure>
When the content is disclosed, the container can be closed in different way: toggling again the visibility via the button (click
or enter/return
), clicking outside of the content, or via the esc
key.
Component API
- Name
-
<:toggle>
- Type
-
named block
- Description
- This is a named block where to pass the interactive element that works as "toggle" for the disclosure.
- Name
-
[:toggle].onClickToggle
- Type
-
event handler
- Description
- Function that needs to be called by the interactive element to toggle the visibility of the content.
- Name
-
[:toggle].isOpen
- Type
-
tracked property
- Description
- Hook into this tracked property if you need to access the state of `isOpen`.
- Name
-
<:content>
- Type
-
named block
- Description
- This is a named block where to pass the actual content that is shown/hidden upon toggling.
- Name
-
[:content].close
- Type
-
function
- Description
- Function that can be called to programmatically close the dropdown.
- Name
-
onClose
- Type
-
function
- Description
- Callback function invoked when the dropdown is closed (if provided).
- Name
-
…attributes
- Description
-
...attributes
spreading is supported on this component.