Make room in your emails with a familiar component
Accordions in Acorn are meant for mobile devices, and they work similar to their website counterparts. For desktop and web email clients, the accordion content will be visible.
<table cellpadding="0" cellspacing="0" role="presentation" width="100%">
<tr>
<td style="padding: 0 24px;">
<div class="spacer py-sm-16" style="line-height: 32px;"></div>
<table cellpadding="0" cellspacing="0" role="presentation" width="100%">
<tr>
<td class="col" width="100%" style="padding: 0 8px;">
<div style="margin-bottom: 24px;">
<a class="toggle-trigger" style="text-decoration: none;">
<button class="toggle-trigger" style="background-color: #EEEEEE; margin: 0; padding: 0; display: block; width: 100%; text-align: left; border: none; outline: none; font-size: 13px;">
<table bgcolor="#EEEEEE" cellpadding="0" cellspacing="0" role="presentation" width="100%">
<tr>
<td style="padding: 16px;">Panel title</td>
</tr>
</table>
</button>
</a>
<div class="toggle-content">
<table cellpadding="0" cellspacing="0" role="presentation" width="100%" style="border: 1px solid #EEEEEE;">
<tr>
<td style="padding: 16px;">
<h2 style="font-size: 26px;">Lorem ipsum dolor</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</td>
</tr>
</table>
</div>
</div>
<div>
<a class="toggle-trigger" style="text-decoration: none;">
<button class="toggle-trigger" style="background-color: #EEEEEE; margin: 0; padding: 0; display: block; width: 100%; text-align: left; border: none; outline: none; font-size: 13px;">
<table bgcolor="#EEEEEE" cellpadding="0" cellspacing="0" role="presentation" width="100%">
<tr>
<td style="padding: 16px;">Panel title</td>
</tr>
</table>
</button>
</a>
<div class="toggle-content">
<table cellpadding="0" cellspacing="0" width="100%" role="presentation" style="border: 1px solid #EEEEEE;">
<tr>
<td style="padding: 16px;">
<h2 style="font-size: 26px;">Lorem ipsum dolor</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</td>
</tr>
</table>
</div>
</div>
</td>
</tr>
</table>
<div class="spacer py-sm-16" style="line-height: 32px;"></div>
</td>
</tr>
</table>
Shared Styles
Accordions need some CSS for mobile, which is included in Acorn's boilerplate. This CSS is shared with hamburger menus, so if you don't use accordions and hamburger menus at all in your email you can safely delete the following associated styles:
.toggle-content {
max-height: 0;
overflow: auto;
transition: max-height .4s linear;
-webkit-transition: max-height .4s linear;
}
.toggle-trigger:hover + .toggle-content,
.toggle-content:hover {max-height: 999px!important;}
Compatibility
Accordions in Acorn use a <button>
tags and CSS :hover
combination, to provide decent client support while not having you worry about unique checkbox IDs and repeated styles.
However, do note that only a few email clients support :hover
. In addition to that, some email service providers, like MailChimp, do not allow form elements (which is what buttons are), so remember to always test.