Toggles have a clickable link and icon pair that show or hide a block of content. Use a Toggle when you need a simple way of showing, hiding and breaking down lengthy content. When the page loads, the Toggle icon and link are shown, but the content is hidden. When the icon or link are clicked the content will then be revealed.
This is an example of disclaimer content. The aria-expanded="true" attribute will be viewable in the DOM on the toggle link when this content is shown. When this content is hidden the aria-expanded attribute will have the value of false. This helps accessibilty devices in understanding that the link is a control for expandable content.
<div data-sprk-toggle="container">
<a class="sprk-b-TypeBodyThree sprk-b-Link sprk-b-Link--standalone" data-sprk-toggle="trigger" href="#">
<svg class="sprk-c-Icon sprk-u-mrs" data-sprk-toggle="icon" viewBox="0 0 448 512">
<use xlink:href="#chevron-down"></use>
</svg>
My Disclaimer
</a>
<p class="sprk-b-TypeBodyFour sprk-u-pts sprk-u-HideWhenJs" data-sprk-toggle="content">
This is an example of disclaimer content. The aria-expanded="true" attribute will be viewable in the DOM on the toggle link when this content is shown. When this content is hidden the aria-expanded attribute will have the value of false. This helps accessibilty devices in understanding that the link is a control for expandable content.
</p>
</div>
<sprk-toggle title="My Disclaimer" body="This is an example of disclaimer content. The aria-expanded=true attribute will be viewable in the DOM on the toggle link when this content is shown. When this content is hidden the aria-expanded attribute will have the value of false. This helps accessibilty devices in understanding that the link is a control for expandable content." analyticsString="My Disclaimer">
</sprk-toggle>
See below for available customization options:
Input | Type | Description |
---|---|---|
title | string | The value supplied will be rendered as the main toggle link text. |
body | string | The value supplied will be rendered as the toggle body content that appears after a click. |
analyticsString | string | The value supplied will be assigned to the 'data-analytics' attribute on the toggle link. Intended for an outside library to capture data. |
additionalClasses | string | Allows a string of classes to add, in addition to the Spark classes. Intended for overrides. |