Gradient Glow Button
A call-to-action button with a gradient fill and a soft coloured glow on hover.
6 फ्रेमवर्कशुरुआती
A red button that arms on the first click and only deletes on the second.
<!--
Colour alone is not a safeguard - red is invisible to a red-blind user and
means nothing to a screen reader. The confirm step is the actual protection:
the first click only arms the button, the second one deletes.
-->
<button class="danger-btn" type="button" data-armed="false">
<span class="danger-btn__label" aria-live="polite">Delete project</span>
</button>
<script>
document.querySelectorAll('.danger-btn').forEach(function (button) {
var label = button.querySelector('.danger-btn__label');
var idle = label.textContent;
var timer;
function disarm() {
button.dataset.armed = 'false';
label.textContent = idle;
window.clearTimeout(timer);
}
button.addEventListener('click', function () {
if (button.dataset.armed !== 'true') {
button.dataset.armed = 'true';
label.textContent = 'Are you sure?';
// Disarm on its own so a forgotten armed button is not a landmine for
// the next person who clicks it.
timer = window.setTimeout(disarm, 4000);
return;
}
disarm();
// Real deletion goes here.
console.log('deleted');
});
// Leaving the button is a signal the user changed their mind.
button.addEventListener('blur', disarm);
});
</script>| Prop | टाइप | डिफ़ॉल्ट | विवरण |
|---|---|---|---|
childrenआवश्यक | ReactNode | - | कंपोनेंट के अंदर रेंडर होने वाला कंटेंट। |
onConfirm | () => void | - | डिस्ट्रक्टिव ऐक्शन कन्फ़र्म होने पर एक बार चलता है। |
disabled | boolean | false | इंटरैक्शन रोकता है और कंट्रोल को धुँधला कर देता है। |
Red is not the safeguard - it is invisible to a red-blind user and means nothing to a screen reader. The confirm step is the protection, and `aria-live` is what carries it. The type omits `onClick` and exposes `onConfirm` instead, so wiring the deletion to the arming click is not expressible. It disarms on blur and after four seconds, so an armed button left alone cannot ambush the next click that lands on it.