🇯🇵 日本語 | 🇺🇸 English | 🇪🇸 Español | 🇵🇹 Português | 🇹🇭 ไทย | 🇨🇳 中文

CSS Template: Disabled Button Style (button:disabled)

📝 Use Case

This template is useful when you want to visually communicate that a button is inactive. It can be used in forms or interfaces where actions are disabled, giving clear feedback to users.

📘 Explanation

The :disabled pseudo-class is used to apply specific styles to a disabled button. By adjusting opacity and changing the cursor to not-allowed, we can clearly show that the button cannot be interacted with.

🔹 Partial Code

<button class="disabled-button" disabled>Cannot Submit</button>

<style>
  .disabled-button {
    background-color: #999;
    color: #fff;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: not-allowed;
    opacity: 0.6;
  }

  .disabled-button:disabled {
    background-color: #ccc;
    color: #666;
    cursor: not-allowed;
    opacity: 0.5;
  }
</style>

🔸 Full HTML Code

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Disabled Button</title>
  <link rel="stylesheet" href="/assets/css/template-common.css?v=1">
  <style>
    .disabled-button {
      background-color: #999;
      color: #fff;
      padding: 10px 20px;
      border: none;
      border-radius: 6px;
      font-size: 1rem;
      cursor: not-allowed;
      opacity: 0.6;
    }

    .disabled-button:disabled {
      background-color: #ccc;
      color: #666;
      cursor: not-allowed;
      opacity: 0.5;
    }
  </style>
</head>
<body>
  <button class="disabled-button" disabled>Cannot Submit</button>
</body>
</html>
Copied!

🚦 UX Design Techniques for Disabled Buttons

The :disabled state styling of buttons is a crucial element that significantly affects the usability of a user interface. Providing proper visual feedback helps prevent user confusion.

🎨 Design Best Practices

Clearly express the disabled state using the following elements:
- Lower the opacity to make it semi-transparent
- Change the background color to a gray tone
- Use cursor: not-allowed to indicate it's not interactive
- Soften the text color to reduce contrast

✨ Enhancing Interaction

Using transition to smoothly animate from disabled to enabled state makes the change more noticeable to the user. It’s also effective to show a tooltip explaining why the button is disabled.

⚠️ Accessibility Considerations

To support users with color vision deficiencies, don’t rely on color alone—use shapes or patterns as well. Ensure ARIA attributes are properly set so that screen readers can convey the button's state.

The ideal disabled button design should also communicate why it can't be interacted with. It should be clearly distinguishable, but not overly attention-grabbing—striking the right balance is key.