मुख्य सामग्री पर जाएं
बटन·मुफ़्त

बटन सेट (HTML + CSS)

सादे CSS में प्राइमरी, सेकेंडरी, डेंजर और शांत बटन, साथ में डिसेबल और लोडिंग स्टेट। हर बटन कम से कम 44 × 44 px का है और कीबोर्ड से पहुँचने पर फ़ोकस रिंग दिखाता है। डार्क मोड में रंग बदल जाते हैं और कंट्रास्ट बना रहता है।

मुफ़्त में इंस्टॉल करें।

अगर आपके Android डिवाइस पर PocketCode इंस्टॉल है, तो यह पेज ऐप में खुलेगा।

प्रीव्यू

buttons.html · 77 लाइनें
<!--
  Button set in plain HTML and CSS: primary, secondary, danger and quiet, plus a loading state.
  Every button is at least 44 x 44 px and shows a focus ring when reached with the keyboard.
  While a request runs, set aria-busy="true" and aria-disabled="true" on the button: the label is hidden
  behind a spinner but screen readers still read it. aria-disabled does not block clicks, so your click
  handler should return early while aria-busy is set. Remove both attributes when it finishes.
  Colours live in the CSS variables; dark mode follows the system setting.
-->
<style>
  .btn {
    --btn-bg: #1f5fd1;
    --btn-fg: #ffffff;
    --btn-border: transparent;
    --btn-ring: #1f5fd1;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 44px;
    min-height: 44px;
    padding: 10px 18px;
    border: 1px solid var(--btn-border);
    border-radius: 10px;
    background: var(--btn-bg);
    color: var(--btn-fg);
    font: 600 15px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    text-decoration: none;
    cursor: pointer;
    transition: filter 0.15s ease;
  }
  .btn-secondary { --btn-bg: transparent; --btn-fg: #1f5fd1; --btn-border: #7c7c88; }
  .btn-danger { --btn-bg: #b3261e; --btn-fg: #ffffff; --btn-ring: #b3261e; }
  .btn-quiet { --btn-bg: transparent; --btn-fg: #1b1b1f; --btn-ring: #1b1b1f; }

  @media (prefers-color-scheme: dark) {
    .btn { --btn-bg: #8ab4ff; --btn-fg: #0b1a33; --btn-ring: #8ab4ff; }
    .btn-secondary { --btn-bg: transparent; --btn-fg: #8ab4ff; --btn-border: #7c7c88; }
    .btn-danger { --btn-bg: #ffb4ab; --btn-fg: #5c0f0a; --btn-ring: #ffb4ab; }
    .btn-quiet { --btn-bg: transparent; --btn-fg: #ececf1; --btn-ring: #ececf1; }
  }

  .btn:hover { filter: brightness(1.1); }
  .btn:active { filter: brightness(0.92); }
  .btn:focus-visible { outline: 2px solid var(--btn-ring); outline-offset: 2px; }
  .btn:disabled,
  .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; filter: none; }

  .btn[aria-busy="true"] { opacity: 1; color: transparent; cursor: progress; }
  .btn[aria-busy="true"]::after {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    border: 2px solid var(--btn-fg);
    border-right-color: transparent;
    border-radius: 50%;
    animation: btn-spin 0.8s linear infinite;
  }
  @keyframes btn-spin { to { transform: rotate(360deg); } }
  @media (prefers-reduced-motion: reduce) {
    .btn { transition: none; }
    .btn[aria-busy="true"]::after { animation-duration: 2.4s; }
  }

  .btn-row { display: flex; flex-wrap: wrap; gap: 12px; }
</style>

<div class="btn-row">
  <button class="btn" type="button">Save changes</button>
  <button class="btn btn-secondary" type="button">Cancel</button>
  <button class="btn btn-danger" type="button">Delete</button>
  <button class="btn btn-quiet" type="button">Skip for now</button>
  <button class="btn" type="button" aria-busy="true" aria-disabled="true">Saving</button>
  <button class="btn" type="button" disabled>Not available</button>
  <a class="btn btn-secondary" href="#pricing">See pricing</a>
</div>

1.0.0 में बदलाव

पहला संस्करण।

संबंधित

बटन (React + Tailwind)मुफ़्तबटनTypeScript बटन, जिसमें प्राइमरी और सेकेंडरी स्टाइल, साफ़ दिखने वाली फ़ोकस रिंग और एक लोडिंग स्पिनर है जो aria-busy भी सेट करता है। सेकेंडरी स्टाइल में डार्क मोड के रंग हैं।एसिंक बटन (Vue)मुफ़्तबटनVue 3 बटन जो एक एसिंक काम चलाता है, इंतज़ार के दौरान स्पिनर दिखाता है और काम पूरा होने तक अतिरिक्त टैप अनदेखे करता है। यह done या error भेजता है, ताकि आगे क्या दिखाना है यह आप तय करें। TypeScript, कोई लाइब्रेरी नहीं।प्राइमरी बटन (Compose)मुफ़्तबटनMaterial 3 बटन जो टैप करने पर हल्का-सा वाइब्रेट करता है। loading = true करने पर यह स्पिनर दिखाता है और अनुरोध चलने तक टैप को अनदेखा करता है।संपर्क फ़ॉर्म (HTML + CSS)मुफ़्तपेजएक ही HTML फ़ाइल में संपर्क फ़ॉर्म: नाम, ईमेल, वैकल्पिक विषय और संदेश। हर फ़ील्ड का अपना लेबल है, और लाल बॉर्डर तभी दिखता है जब कोई उसमें लिख चुका हो या भेजने की कोशिश कर चुका हो। फ़ॉर्म के action में अपना एंडपॉइंट डालें। डार्क मोड सिस्टम के अनुसार चलता है।कॉपी बटन (React)मुफ़्तबटनReact और TypeScript का बटन जो किसी टेक्स्ट को क्लिपबोर्ड पर कॉपी करता है। दो सेकंड तक लेबल "Copied" दिखाता है और एक छिपी स्टेटस लाइन स्क्रीन रीडर को बताती है। किसी CSS फ़्रेमवर्क की ज़रूरत नहीं, और सादे http पर चलने वाले पेज पर यह पुराना कॉपी कमांड इस्तेमाल करता है।टॉगल स्विच (Svelte)मुफ़्तबटनSvelte 5 के लिए ऑन/ऑफ़ स्विच, जो role switch वाले बटन से बना है, इसलिए Space, Enter और स्क्रीन रीडर काम करते हैं। checked बाइंड करें या onchange दें। इसमें वैकल्पिक दूसरी लाइन, बंद (disabled) स्थिति और CSS वैरिएबल से रंग हैं।