SnippetUI

Cyberpunk Glitch Button

A futuristic button featuring a neon glow and subtle glitch animation that looks great in dark mode.

HTMLCSS

Preview

A button featuring neon colors and a hover glitch effect, perfect for dark themes or sci-fi-inspired UIs.

Use Cases and Features

  • Cyberpunk and Sci-Fi Design: Ideal for game UIs, Web3-related sites, creative portfolios, and projects where you want to evoke an extraordinary or futuristic atmosphere.
  • Neon Glow and Glitch: On hover, the base color shifts and an aggressive glitch (bug) animation is triggered, delivering a strong visual impact to the user.
  • Shapes Powered by CSS clip-path: The distinctive shape with “chipped” corners is created entirely using clip-path rather than images, ensuring it is lightweight and fully responsive.

Design and UX Insights

  1. Visual Feedback: The dramatic change on hover (a color shift from cyan to magenta along with a glow) clearly communicates that the element is interactive.
  2. Multi-Layer Structure: By combining ::before, ::after, and a decorative element (.decoration), it achieves a framed design with a sense of depth.
  3. Accessibility Considerations: The duplicated text used for the glitch effect is given aria-hidden="true" to prevent it from interfering with screen readers.

Customization Guide

By simply changing the CSS variables, you can create a cyberpunk button tailored to your project’s theme colors.

.cyber-btn {
  /* メインカラー(通常時の色) */
  --primary-color: #00ffcc;
  
  /* セカンダリカラー(ホバー時の色) */
  --secondary-color: #ff00ff;
  
  /* 背景色(内側の暗い部分) */
  --bg-color: #050505;
}

Using a monospaced font (monospace) further enhances the hacking UI or system console aesthetic.

Implementation Code

<button class="cyber-btn">
<span class="main-text">SYSTEM_READY</span>
<span class="glitch-text" aria-hidden="true">SYSTEM_READY</span>
<span class="decoration"></span>
</button>

<style>
/* カスタムプロパティと基本スタイル */
.cyber-btn {
--primary-color: #00ffcc;
--secondary-color: #ff00ff;
--bg-color: #050505;

position: relative;
padding: 1rem 2.5rem;
font-family: 'Courier New', Courier, monospace;
font-size: 1.2rem;
font-weight: bold;
letter-spacing: 0.15em;
color: var(--primary-color);
background-color: transparent;
border: none;
cursor: pointer;
outline: none;
text-transform: uppercase;
}

/* 背景レイヤー */
.cyber-btn::before,
.cyber-btn::after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 0;
transition: all 0.3s ease;
}

/* 外側のフレーム(角欠け形状) */
.cyber-btn::before {
background-color: var(--primary-color);
clip-path: polygon(0 0, 100% 0, 100% calc(100% - 15px), calc(100% - 15px) 100%, 0 100%);
z-index: -2;
}

/* 内側の背景(フレームとの差分でボーダーを表現) */
.cyber-btn::after {
background-color: var(--bg-color);
clip-path: polygon(2px 2px, calc(100% - 2px) 2px, calc(100% - 2px) calc(100% - 16px), calc(100% - 16px) calc(100% - 2px), 2px calc(100% - 2px));
z-index: -1;
}

/* グリッチ用の隠しテキスト */
.cyber-btn .glitch-text {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
background-color: var(--bg-color);
color: var(--secondary-color);
clip-path: polygon(2px 2px, calc(100% - 2px) 2px, calc(100% - 2px) calc(100% - 16px), calc(100% - 16px) calc(100% - 2px), 2px calc(100% - 2px));
opacity: 0;
z-index: 1;
}

/* メインテキスト */
.cyber-btn .main-text {
position: relative;
z-index: 2;
text-shadow: 0 0 8px rgba(0, 255, 204, 0.5);
transition: all 0.3s ease;
}

/* ホバー時のスタイル変更 */
.cyber-btn:hover::before {
background-color: var(--secondary-color);
box-shadow: 0 0 20px var(--secondary-color);
}

.cyber-btn:hover .main-text {
opacity: 0;
}

.cyber-btn:hover .glitch-text {
opacity: 1;
animation: cyber-glitch-anim 0.25s cubic-bezier(.25, .46, .45, .94) both infinite;
}

/* 右下の小さな三角形の装飾 */
.cyber-btn .decoration {
position: absolute;
bottom: -1px;
right: -1px;
width: 20px;
height: 20px;
background-color: var(--primary-color);
clip-path: polygon(100% 0, 100% 100%, 0 100%);
z-index: 3;
transition: all 0.3s ease;
}

.cyber-btn:hover .decoration {
background-color: var(--secondary-color);
box-shadow: 0 0 10px var(--secondary-color);
}

/* グリッチアニメーションの定義 */
@keyframes cyber-glitch-anim {
0% {
  clip-path: polygon(0 10%, 100% 10%, 100% 20%, 0 20%);
  transform: translate(-4px, 2px);
  color: var(--primary-color);
}
20% {
  clip-path: polygon(0 40%, 100% 40%, 100% 50%, 0 50%);
  transform: translate(4px, -2px);
  color: #fff;
}
40% {
  clip-path: polygon(0 70%, 100% 70%, 100% 80%, 0 80%);
  transform: translate(-4px, 2px);
  color: var(--secondary-color);
}
60% {
  clip-path: polygon(0 15%, 100% 15%, 100% 30%, 0 30%);
  transform: translate(4px, 2px);
  color: var(--primary-color);
}
80% {
  clip-path: polygon(0 80%, 100% 80%, 100% 90%, 0 90%);
  transform: translate(-2px, -2px);
  color: #ff0;
}
100% {
  clip-path: polygon(0 50%, 100% 50%, 100% 60%, 0 60%);
  transform: translate(2px, -2px);
  color: var(--secondary-color);
}
}
</style>

Browser Support

It uses clip-path and basic CSS animations. It works flawlessly in all modern major browsers.

  • Chrome: 55+
  • Firefox: 54+
  • Safari: 10.1+
  • Edge: 79+