Design
When designing forms, it is often useful to hide a set of controls until the user actually needs them. This declutters the interface and draws attention to the additional form inputs when they are revealed.
To support this, ACE supports an Auto-reveal feature on checkboxes, radio buttons and Toggles. When set, content can be revealed or hidden when a certain item is selected.
Code
There are two parts to using auto-reveal:
- Set an attribute on the trigger element (checkbox, radio or Toggle), which includes the selector string which locates the element(s) you want to show or hide.
- To show content while the trigger is checked, use
data-ace-reveal-on
- To show content while the trigger is NOT checked, use
data-ace-reveal-off
- To show content while the trigger is checked, use
- Set the initial shown or hidden state on the target content using
aria-hidden
set totrue
orfalse
.
Example | Element | Code |
---|---|---|
Reveal when on - show the related content when the trigger element is checked. |
Set the attribute
In the short term, use custom attributes to set the Auto-reveal and aria-hidden attributes. |
|
Reveal when off - show the related content when the trigger element is not checked. |
In the short term, use custom attributes to set the Auto-reveal and aria-hidden attributes. |