cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

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.

              <button class="o-btn" aria-expanded="false">Show dialogue</button>
<div class="o-dialogue" aria-hidden="true" tabindex="-1">
	<h2 class="o-dialogue__heading">Oh, hey there</h2>
	<p class="o-dialogue__summary">Remember, you can use your <kbd>esc</kbd> key to close me!</p>
	<button class="[ o-btn o-btn--small ] [ o-dialogue__btn ]" aria-expanded="false">Close window</button>
              // Vars 
$primary: #34495e;
$primary--light: #527395;
$secondary: #d35400;
$radius: 3px;
$transition: all 250ms cubic-bezier(0.675, 0.420, 0.090, 0.870);

// Core
body {
	font-size: 16px;
	background: #f3f3f3;
	display: flex;
	justify-content: center;
	align-items: center;
	position: relative;
	font-family: 'Lato';

kbd {
	padding: 2px;
	border: 1px solid $secondary;
	border-radius: $radius;

// Button object 
.o-btn {
	display: inline-block;
	appearance: none;
	border: none;
	padding: 0;
	margin: 0;
	text-decoration: none;
	font-family: 'Lato';
	font-weight: 900;
	font-size: 1.3rem;
	line-height: 1;
	padding: 15px 25px 17px 25px;
	border-radius: $radius;
	background: $primary;
	color: #fff;
	cursor: pointer;
	&:focus {
		background: $primary--light;
	&:focus {
		outline: none;
		box-shadow: 0 0 0 3px $secondary;
	// Modifiers
	&--small {
		font-size: 0.88rem;
		padding: 10px 15px;

// Dialogue 
.o-dialogue {
	display: block;
	max-width: 400px;
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate3d(-50%, -30%, 0);
	background: #ffffff;
	padding: 20px;
	margin: 20px;
	border-radius: $radius;
	box-shadow: 0px 10px 20px rgba(0, 0, 0, 0.2);
	transition: $transition;
	opacity: 0;
	visibility: hidden;
	&__summary {
		padding-top: 10px;
		display: block;
	&__btn {
		margin-top: 20px;
	// Show the dialogue
	&[aria-hidden="false"] {
		opacity: 1;
		visibility: visible;
		transform: translate3d(-50%, -50%, 0);
              var hidden = true;
const buttonElems = [...document.querySelectorAll('.o-btn')];
const dialogueElem = document.querySelector('.o-dialogue');

const toggle = (state = !hidden) => {
	// Loop buttons and reverse expanded attribute
	buttonElems.map(buttonElem => {
		buttonElem.setAttribute('aria-expanded', (state ? 'false' : 'true'));
	// Set the hidden attribute to the opposite of state
	dialogueElem.setAttribute('aria-hidden', (state ? 'true' : 'false'));

	// Focus the dialogue if it's visible
	if(!state) {
		dialogueElem.setAttribute('tab-index', '0');
	else {
		dialogueElem.setAttribute('tab-index', '-1');
		// Focus the 'show dialogue' button
	// Set the global hidden flag to the state value
	hidden = state;

// Attach toggle function to button click events
buttonElems.map(buttonElem => {
	buttonElem.addEventListener('click', (evt) => {

// Bind the toggle function to the escape key
document.addEventListener('keyup', (evt) => {
    if(evt.keyCode === 27) {
		// Force the closure by passing custom state
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................