Pen Settings

HTML

CSS

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

JavaScript

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

Packages

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.

Behavior

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.

HTML

              
                <button class='trigger-button' onClick='document.getElementById("dialog").showModal();'>
	<span>
		Open Dialog
		<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="icon">
			<path d="M9.375 3a1.875 1.875 0 0 0 0 3.75h1.875v4.5H3.375A1.875 1.875 0 0 1 1.5 9.375v-.75c0-1.036.84-1.875 1.875-1.875h3.193A3.375 3.375 0 0 1 12 2.753a3.375 3.375 0 0 1 5.432 3.997h3.943c1.035 0 1.875.84 1.875 1.875v.75c0 1.036-.84 1.875-1.875 1.875H12.75v-4.5h1.875a1.875 1.875 0 1 0-1.875-1.875V6.75h-1.5V4.875C11.25 3.839 10.41 3 9.375 3ZM11.25 12.75H3v6.75a2.25 2.25 0 0 0 2.25 2.25h6v-9ZM12.75 12.75v9h6.75a2.25 2.25 0 0 0 2.25-2.25v-6.75h-9Z" />
		</svg>
	</span>
</button>

<dialog id="dialog">
		<form method="dialog">
			<button class='close-button'>
				Close
				<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class='icon'>
					<path fill-rule="evenodd" d="M12 2.25c-5.385 0-9.75 4.365-9.75 9.75s4.365 9.75 9.75 9.75 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25Zm-1.72 6.97a.75.75 0 1 0-1.06 1.06L10.94 12l-1.72 1.72a.75.75 0 1 0 1.06 1.06L12 13.06l1.72 1.72a.75.75 0 1 0 1.06-1.06L13.06 12l1.72-1.72a.75.75 0 1 0-1.06-1.06L12 10.94l-1.72-1.72Z" clip-rule="evenodd" />
				</svg>
			</button>
		</form>
		<div class='dialog-wrapper'>
			<h2>Dialog Light Dismiss</h2>
			<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent eu ligula elit. Fusce et metus massa. Fusce scelerisque lacus erat, et mollis ante tincidunt at. Etiam sed porta lacus, et aliquam dolor. Ut euismod augue eu iaculis condimentum. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aliquam elementum sapien nec justo congue, vitae pharetra ipsum posuere. Proin commodo arcu quis enim ultrices tempus. Phasellus tellus mauris, sagittis in ex eu, elementum euismod libero.</p>
		</div>
	</div>
</dialog>
              
            
!

CSS

              
                :root,::backdrop {
	--color: #333;
	--background: #fefefe;
	--focus: #ff0078;
	--grid-size: 50px;
	--grid-width: 0.9px;
}

::backdrop {
	background: color-mix(in lch, var(--color), transparent 60%);
}

.icon {
	width: 1em;
	height: 1em;
	transform: scale(1.2);
}

body {
	color: var(--color);
	background: var(--background);
	font-family: system-ui, sans-serif;
	&::before {
		content: '';
		inset: 0;
		position: fixed;
		background-image: repeating-linear-gradient(transparent, transparent var(--grid-size),color-mix(in lch, var(--color), transparent 80%) 0, color-mix(in lch, var(--color), transparent 80%) calc(var(--grid-size) + var(--grid-width))), repeating-linear-gradient(90deg, transparent, transparent var(--grid-size),color-mix(in lch, var(--color), transparent 80%) 0, color-mix(in lch, var(--color), transparent 80%) calc(var(--grid-size) + var(--grid-width)));
		mask-image: linear-gradient(-45deg, transparent 50%,black);
	}
}

h2,p {
	margin: 0;
}

button, dialog {
	padding: 0;
	border: 0;
	background: none;
}

button {
	cursor: pointer;
}

.dialog-wrapper {
	
	max-height: 50vh;
	color: var(--color);
	background: var(--background);
	border: 4px solid var(--color);
	max-width: 500px;
	border-radius: 20px;
	padding: 2em;
	position: relative;
	z-index: 1;
	box-shadow: 1px 1px 0px 0px var(--color), 2px 2px 0px 0px var(--color), 3px 3px 0px 0px var(--color),4px 4px 0px 0px var(--color),5px 5px 0px 0px var(--color);
}

dialog {
	overflow-y: auto;
	padding: 20px;
	&,::backdrop {
		transition: display 0.3s allow-discrete, overlay 0.3s allow-discrete;
	}
	
	animation: exit 0.3s forwards ease, fade-out 0.3s forwards ease;

	&[open] {
		animation: enter 0.3s ease, fade-in 0.3s forwards ease;
		transform: none;
	}
	
	&::backdrop {
		animation: fade-out 0.3s forwards ease;
	}
	&[open]::backdrop {
		animation: fade-in 0.3s forwards ease;
	}
}

.trigger-button {
	--color: #333;
	--background: white;
	
	outline: none;
	&:focus-visible span {
	 	outline: 5px dashed var(--focus);
		outline-offset: 3px;
	}
	
	transition: transform 0.2s cubic-bezier(.3, .7, .4, 1);
	font-weight: bold;
	text-transform: uppercase;
	display: block;
	max-width: max-content;
	position: relative;
	font-size: 1.2rem;
	border-radius: 999px;
	
	span {
		display: flex;
		gap: 0.5em;
		align-items: center;
		max-width: max-content;
		background: var(--background);
		color: var(--color);
		border: 4px solid var(--color);
		padding: 0.8em 1.6em;
		position: relative;
		overflow: hidden;
	}
	
	&::before,&::after,span::before,span {
		transition: inherit;
		border-radius: inherit;
		box-shadow: 1px 1px 0px 0px var(--color), 2px 2px 0px 0px var(--color), 3px 3px 0px 0px var(--color);
	}
	
	&::before,&::after,span::before {
		content: '';
		z-index: -1;
		position: absolute;
		inset:0;
	}
	
	&::before {
		transform: translate(2px,2px);
	}	
	
	&:hover {
		span {
			transform: translate(-2px,-2px);
		}
	}
	
	&:active {
		span, &::after {
			transform: translate(2px,2px);
		}
	}
	
}

html, body  {
	height: 100%;
}
body {
	margin: 0;
	display: grid;
	place-items: center;
}

@keyframes fade-in {
	from { 
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

@keyframes fade-out {
	from {
		opacity: 1;
	}
	to {
		opacity: 0;
	}
}

@keyframes enter {
	from {
		translate: 0px -30px;
	}
	to {
		translate: 0px 0px;
	}
}

@keyframes exit {
	from {
		translate: 0px 0px;
	}
	to {
		translate: 0px 30px;
	}
}

.close-button {
	margin-left: auto;
	margin-bottom: 20px;
		display: flex;
	align-items: center;
	gap: 0.5em;
		max-width: max-content;
		background: var(--background);
		color: var(--color);
		border: 4px solid var(--color);
		padding: 0.6em 1.2em;
		position: relative;
		overflow: hidden;
	font-size: 0.8rem;
	border-radius: 999px;
	font-weight: bold;
	text-transform: uppercase;
	box-shadow: 1px 1px 0px 0px var(--color), 2px 2px 0px 0px var(--color), 3px 3px 0px 0px var(--color),4px 4px 0px 0px var(--color),5px 5px 0px 0px var(--color);
	transition: color 0.3s ease, background 0.3s ease;
	
	&::before {
		content: '';
		position: fixed;
		inset: 0;
		z-index: -1;
	}
	
	&:focus-visible {
	 	outline: 5px dashed var(--focus);
		outline-offset: 3px;
	}
	
	&:hover {
		color: var(--background);
		background: var(--color);
	}
}

[method="dialog"] {
	display: contents;
}
              
            
!

JS

              
                
              
            
!
999px

Console