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.


                <progress-indicator role="progressbar"></progress-indicator>

Make sure to use `aria-labelledby` to specify what kind of progress indicator it is.
Optionally. also use `aria-describedby` to convey what is being loaded.


                @layer globals {
	*::after {
		box-sizing: border-box;
	:root {
		--font-base: "Space Mono", monospace;
		--color-dark: #1f1a38;
		--color-dark-glare: #989ea9;
		--color-success: #76f7bf;

		font-family: var(--font-base), system-ui;
	body {
		min-block-size: 100dvb;
		display: grid;
		place-items: center;

@layer components.progressbar {
	/* This custom property is the source of truth, the center of attention. */
	@property --progress-value {
		syntax: "<number>";
		inherits: true;
		initial-value: 0;

	[role="progressbar"] {
		/* CSS "API" for customizing the cosmetic parts. */
		@layer settings {
			--progress-size: 4rem;
			--progress-track: var(--color-dark);
			--progress-track-bg: var(--color-dark-glare);
			--progress-thickness: 6px;
			--progress-complete-bg: var(--color-success);
			--progress-complete-svg: url('data:image/svg+xml;utf-8,<svg xmlns="" width="32" height="32" viewBox="0 0 24 24"><path d="m9 19.414l-6.707-6.707l1.414-1.414L9 16.586L20.293 5.293l1.414 1.414z"/></svg>');

		@layer base {
			display: block;
			block-size: var(--progress-size);
			aspect-ratio: 1;
			position: relative;
			border-radius: 9e9px;
			display: grid;
			place-items: center;

			&::after {
				content: "";
				position: absolute;
				inset: 0;
				display: block;
				border-radius: inherit;
				border: var(--progress-thickness) solid transparent;

			&::before {
				border-color: var(--progress-track-bg);

			&::after {
				--_progress-percent: calc(var(--progress-value) * 1%);
				background-color: var(--progress-track);
				mask-image: conic-gradient(
						#000 var(--_progress-percent),
						#0000 var(--_progress-percent)
					linear-gradient(#000 0, #000 0);
				mask-clip: border-box, content-box;
				mask-composite: subtract;

		@layer states {
			&[data-completed="true"] {
				background-color: var(--progress-complete-bg);

				&::before {
					mask: var(--progress-complete-svg) no-repeat center;
					background-color: var(--progress-track);

		@layer overrides {
 			/* Fix colors for Windows contrast themes */
			@media (forced-colors: active) {
				--progress-track-bg: Canvas;
				--progress-track: CanvasText;



                import * as announcer from "";

announcer.setup(); //

// -------------------------------------------------------

class ProgressIndicator extends HTMLElement {
	static {
		customElements.define("progress-indicator", this);
	constructor() {

		// use shadow DOM to add show the value% inside the spinner.
		this.attachShadow({ mode: "open" });
		this.centerElement = document.createElement("span");
		this.centerElement.setAttribute("aria-hidden", "true"); // hiding from AT because aria-valuenow already handles it
		// hydrate the value property using initial HTML state
		this.value = getComputedStyle(this).getPropertyValue("--progress-value");

	get value() {
		return Number(this.#value);
	set value(value) {
		value = Math.max(0, Math.min(value, 100));
		this.#value = value;"--progress-value", `${value}`);
		this.setAttribute("aria-valuenow", value);
		this.centerElement.textContent = `${value}%`;

		 * We could use the live region to announce updates every few seconds, but it
		 * could get noisy and may be unnecessary if the progress only takes a short time.
		// throttle(() => announcer.notify(`Progress: ${value}%`));

		if (value === 100) {
			this.dataset.completed = "true";
			this.centerElement.textContent = ""; // clear the % text

			// only announce the final completion using live region
			setTimeout(() => announcer.notify("Progress finished!"), 200);
		} else {
			delete this.dataset.completed;

// -------------------------------------------------------

const progress = document.querySelector("progress-indicator");

// increment until 100%
const interval = setInterval(() => {
	progress.value += 1;
	if (progress.value >= 100) clearInterval(interval);
}, 100);