Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


	<h1>Accessible Multi-select Accordion</h1>
	<dl class="accordion">
			<button class="accordion__button" aria-expanded="true" aria-controls="accordion-resources">What resources did you use to build this?</button>
		<dd class="accordion__content" id="accordion-resources" aria-hidden="false">
				<li><a href="">Disclosure (FAQ) Design Pattern</a></li>
				<li><a href="">Disclosure (FAQ) Example</a></li>
				<li><a href="">Accordion Design Pattern</a></li>
				<li><a href="">Accordion Example</a></li>

			<button class="accordion__button" aria-expanded="true" aria-controls="accordion-markup">What are the HTML tags and ARIA attributes used?</button>
		<dd class="accordion__content" id="accordion-markup" aria-hidden="false">
				<li><a href="">section</a></li>
				<li><a href="">button</a></li>
				<li><a href="">dl</a></li>
				<li><a href="">dt</a></li>
				<li><a href="">dd</a></li>
				<li><a href="">aria-expanded</a></li>
				<li><a href="">aria-controls</a></li>

			<button class="accordion__button" aria-expanded="true" aria-controls="accordion-behavior">What is the expected behavior of this component?</button>
		<dd class="accordion__content" id="accordion-behavior" aria-hidden="false">
				<li>Users can tab to an accordion button which will show focus that button</li>
				<li>When using a keyboard and the NVDA screen reader users can hit Enter or Space to toggle the content for the focused accordion button</li>
				<li>When using the VO screen reader users can navigate to the button with Control + Option + Space</li>
				<li>Then when focused on the button, VO users can toggle the content with Control + Option + Space</li>


                $theme-primary: #9482ec;
$theme-secondary: #444;

*:focus {
	outline: none;
	box-shadow: 0 0 0 0.125rem #fff, 0 0 0 0.25rem #000;

body {
	padding: 1rem 2rem;
	font-family: 'Roboto', sans-serif;
	background-color: #fff;

h1 {
	text-align: center;
	margin-bottom: 1.5rem;
	font-family: 'Poppins', sans-serif;
	color: $theme-secondary;
	font-size: 2rem;

li {
	margin-bottom: 0.75rem;

a {
	padding: 0.25rem 0.125rem 0;
	color: $theme-primary;
	text-decoration: none;
	border-bottom: 1px solid $theme-primary;
	transition: all 150ms ease;

	&:hover {
		background-color: #cbffd9;
		color: #6a51e7;
		border-bottom: 3px solid #6a51e7;

.accordion {
	max-width: 40rem;
	margin: auto;

	&__button {
		text-align: left;
		font-size: 1rem;
		font-family: 'Poppins', sans-serif;
		font-weight: 500;
		background-color: $theme-primary;
		color: #fff;
		border: none;
		padding: 0.5rem 1rem;
		border-radius: 0.25rem;
		display: block;
		width: 100%;
		z-index: 1; // add z-index so focus is always visible
		position: relative;
		margin-top: 1rem;
		transition: all 150ms linear;
		&::after {
			content: "";
			display: inline-block;
			position: absolute;
			right: 0.875rem;
			top: 0.875rem;
			width: 0.4rem;
			height: 0.4rem;
			border-right: 0.25rem solid #fff;
			border-top: 0.25rem solid #fff;
			transform: rotate(135deg);
			transition: transform 250ms linear;
		&:hover {
			background-color: $theme-secondary;
			transform: scale(1.025);
		&[aria-expanded='true'] {
			background-color: $theme-secondary;
		&[aria-expanded='true']::after {
			transform: rotate(315deg) translateY(0.25rem);
	&__content {
		padding: 0.875rem;
		margin-left: 0;
		background-color: #fff;
		border: 2px solid #eee;
		box-shadow: 1px 4px 10px 1px rgba(0, 0, 0, 0.15);
		transition: all 200ms linear;
		&[aria-hidden='false'] {
			display: block;
		&[aria-hidden='true'] {
			display: none;


                const buttons = document.querySelectorAll('.accordion__button');
const contentSections = document.querySelectorAll('.accordion__content');

function setInitialAriaValue(elements, aria, ariaValue) {
	elements.forEach((element) => {
		element.setAttribute(`${aria}`, `${ariaValue}`);

function accordionToggleHandler() {
	buttons.forEach((button) => {
		button.addEventListener('click', toggleContent);

function toggleContent(e) {

function toggleButton(button) {
	const expandedValue = button.getAttribute('aria-expanded');
	const setValue = expandedValue === 'true' ? 'false' : 'true';
	button.setAttribute('aria-expanded', setValue);

function toggleDetails(button) {
	const buttonAriaControl = button.getAttribute('aria-controls');
	const content = document.getElementById(buttonAriaControl);
  const hiddenValue = content.getAttribute('aria-hidden');
	const setValue = hiddenValue === 'true' ? 'false' : 'true';
	content.setAttribute('aria-hidden', setValue);

setInitialAriaValue(buttons, 'aria-expanded', 'false');
setInitialAriaValue(contentSections, 'aria-hidden', 'true');