<!-- Compare what happens when you click on this button versus tabbing to it. -->
<button>
  Custom button
</button>
<!-- Load the :focus-visible polyfill -->
<script src="https://unpkg.com/focus-visible"></script>
/*
Copyright 2018 Google LLC.
SPDX-License-Identifier: Apache-2.0
*/

body {
  font-family: "Benton Sans", "Helvetica Neue", helvetica, arial, sans-serif;
  margin: 2em;
}

button {
  font-size: 18px;
  border: 2px inset #4a148c;
  border-radius: 8px;
  padding: 16px;
  margin: 0 8px;
  color: #ffffff;
  text-transform: uppercase;
  background: #4a148c;
  box-shadow: 4px 5px 0px #12005e;
}

button:active {
  background: #ffffff;
  color: #4a148c;
}

/*
  This will hide the focus indicator if the element receives focus via the mouse,
  but it will still show up on keyboard focus.
*/
.js-focus-visible button:focus:not(.focus-visible) {
  outline: none;
}

/*
  Optionally: Define a strong focus indicator for keyboard focus.
  If you choose to skip this step then the browser's default focus
  indicator will be displayed instead.
*/
.js-focus-visible button.focus-visible {
  outline: 4px dashed orange;
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.