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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <div class="wrapper">
	<div class="btn">Click Me 1</div>
	<div class="btn">Click Me 2</div>
	<div class="btn">Click Me 3</div>
	<div class="btn">Click Me 4</div>
	<div class="btn">Click Me 5</div>
	<div class="btn">Click Me 6</div>
	<div class="btn">Click Me 7</div>
	<div class="btn">Click Me 8</div>
	<div class="btn">Click Me 9</div>
	<div class="btn">Click Me 10</div>
	<div class="btn">Click Me 11</div>
	<div class="btn">Click Me 12</div>
	<div class="btn">Click Me 13</div>
	<div class="btn">Click Me 14</div>
	<div class="btn">Click Me 15</div>
	<div class="btn">Click Me 16</div>
	<div class="btn">Click Me 17</div>
	<div class="btn">Click Me 18</div>
	<div class="btn">Click Me 19</div>
	<div class="btn">Click Me 20</div>
	<div class="btn">Click Me 21</div>
	<div class="btn">Click Me 22</div>
	<div class="btn">Click Me 23</div>
	<div class="btn">Click Me 24</div>
	<div class="btn">Click Me 25</div>
	<div class="btn">Click Me 26</div>
	<div class="btn">Click Me 27</div>
	<div class="btn">Click Me 28</div>
	<div class="btn">Click Me 29</div>
	<div class="btn">Click Me 30</div>
</div>



<button class="decorate">Convert to </br>pseudo-buttons</button>
            
          
!
            
              * {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	background-color: #545454;
	font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", Tahoma, Roboto, Oxygen, Ubuntu, Cantarell,
        "Fira Sans", "Open Sans", sans-serif;
}

.wrapper {
	max-width: 1200px;
	width: 80%;
	margin: 0 auto;
}

.btn {
	font-size: 1em;
	color: #dcdcdc;
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	min-height: 45px;
	padding: 0 10px;
	border-radius: 2px;
	border: 1px solid #b5b5b5;
	background-color: #616161;
	margin: 2px;
	&:focus {
		border: 1px solid white;
		outline: 0;
	}
	&[aria-pressed="true"] {
		background-color: #e4e4e4;
		color: #137a5a;
	}
}

.decorate {
	position: fixed;
	bottom: 0;
	left: 50%;
	transform: translateX(-50%);
	height: 50px;
	font-size: 1em;
	width: 200px;
}
            
          
!
            
              // Are the btns decorated of not
let decorated = false;

// Grab the button to decorate
var decorate = document.querySelector("button.decorate");
// Grab wrapper
var wrapper = document.querySelector(".wrapper");

// Handle action on the decorate btn
decorate.addEventListener("click", e => {
	decorateBtns();
});

function decorateBtns() {
	if (decorated) {
		return;
	}
	// Grab btns
	let btns = document.querySelectorAll(".btn");
	// decorate them
	btns.forEach((btn, idx) => {
		btn.setAttribute("role", "button");
		btn.setAttribute("aria-pressed", "false");
		btn.setAttribute("tabindex", "0");
	});
	// You don't get keyboard handler by default on converted btns: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/button_role#Required_JavaScript_Features
	wrapper.addEventListener("keydown", e => {
			if (e.key === " " || e.key === "Enter" || e.key === "Spacebar") {
				toggleBtn(e.target);
			}
		});
	decorated = true;
}

function toggleBtn(ele) {
	ele.setAttribute(
		"aria-pressed",
		ele.getAttribute("aria-pressed") === "true" ? "false" : "true"
	);
}

            
          
!
999px
🕑 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.

Console