Native Accordion


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.

Demo Link.

<div class="n-accordion">
	<input type="checkbox" aria-label="Toggle accordion">
	<h2 class="n-accordion__label">
		<button id="accordion-1-button" aria-controls="accordion-1-content">
			Title
		</button>
	</h2>
	<div class="n-accordion__content" role="region" id="accordion-1-content" aria-labelledby="accordion-1-button">
		<p>Content</p>
	</div>
</div>

Open by default

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.

Link third.

<div class="n-accordion">
	<input type="checkbox" checked aria-label="Toggle accordion">
	<h2 class="n-accordion__label">
		<button id="accordion-1-button" aria-controls="accordion-1-content" aria-expanded="true">
			Label
		</button>
	</h2>
	<div class="n-accordion__content" role="region" id="accordion-1-content" aria-labelledby="accordion-1-button">
		<p>Content</p>
	</div>
</div>

Accordion Group

Content 1

Link fourth.

Content 2

Link fifth.

Content 3

Link sixth.

<div role="group">
	<div class="n-accordion">
		...
	</div>
	<div class="n-accordion">
		...
	</div>
	...
</div>

Nested Accordions

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.

Link seventh.

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.

Link eighth.

<div class="n-accordion">
	<input type="checkbox" aria-label="Toggle accordion">
	<h2 class="n-accordion__label">
		<button id="accordion-1-button" aria-controls="accordion-1-content">
			Title
		</button>
	</h2>
	<div class="n-accordion__content" id="accordion-1-content" aria-labelledby="accordion-1-button" role="region">
		<div class="n-accordion">
			...
		</div>	
	</div>
</div>

Pop-in

Content for 1

Content for 2

Content for 3

Content for 4

Content for 5

Content for 6

Content for 7

Content for 8

Content for 9

Content for 10

<div class="n-accordion__popin" role="group">
	<div class="n-accordion">
		...
	</div>
	...
</div>

Mobile only

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.

<div class="n-accordion n-accordion--mobile">
	<input type="checkbox" aria-label="Toggle accordion">
	<h2 class="n-accordion__label">
		<button id="accordion-1-button" aria-controls="accordion-1-content">
			Title
		</button>
	</h2>
	<div class="n-accordion__content"  id="accordion-1-content" aria-labelledby="accordion-1-button" role="region">
		<p>Content</p>
	</div>
</div>

How to use

Get the n-accordion NPM module and either add n-accordion.js and n-accordion.scss to your project
or use n-accordion.min.js and n-accordion.min.css on your page.

Options

Links

GitHub page

Developed by Radoslav Sharapanov, originally a part of the niui library.

Buy me a beer