मुख्य सामग्री पर जाओ डॉक्स नेविगेशन पर जाओ
in English

अलर्ट करदा ऐ

उपलब्ध ते लचीले अलर्ट संदेशें दी मुट्ठी भर कन्नै ठेठ बरतूनी कार्रवाईयें लेई संदर्भ प्रतिक्रिया संदेश उपलब्ध करोआओ।

उदाहरण दे

पाठ दी कुसै बी लंबाई आस्तै अलर्ट उपलब्ध न, ते कन्नै गै इक वैकल्पिक बंद बटन बी उपलब्ध ऐ। उचित स्टाइलिंग आस्तै, अट्ठें जरूरी संदर्भ वर्गें च इक दा इस्तेमाल करो (जियां, .alert-success) । इनलाइन बर्खास्तगी आस्तै, अलर्टें दा इस्तेमाल करो जावास्क्रिप्ट प्लगइन .

<div class="alert alert-primary" role="alert">
  A simple primary alert—check it out!
</div>
<div class="alert alert-secondary" role="alert">
  A simple secondary alert—check it out!
</div>
<div class="alert alert-success" role="alert">
  A simple success alert—check it out!
</div>
<div class="alert alert-danger" role="alert">
  A simple danger alert—check it out!
</div>
<div class="alert alert-warning" role="alert">
  A simple warning alert—check it out!
</div>
<div class="alert alert-info" role="alert">
  A simple info alert—check it out!
</div>
<div class="alert alert-light" role="alert">
  A simple light alert—check it out!
</div>
<div class="alert alert-dark" role="alert">
  A simple dark alert—check it out!
</div>
सहायक प्रौद्योगिकियें गी अर्थ संप्रेषित करना

अर्थ जोड़ने आस्तै रंग दा उपयोग करना सिर्फ इक दृश्य संकेत दिंदा ऐ, जेह् ड़ा सहायक तकनीकें दे बरतूनकर्ताएं गी नेईं पजाया जाग – जि’यां स्क्रीन रीडर। एह् सुनिश्चत करो जे रंग कन्नै दर्शाए गेदे जानकारी गी या तां सामग्री थमां गै स्पष्ट ऐ (जियां दिक्खने आह् ला पाठ), जां वैकल्पिक साधनें राहें शामल कीता जा, जि’यां .visually-hiddenवर्ग कन्नै छिपे दा अतिरिक्त पाठ।

लाइव मिसाल

इक अलर्ट दस्सने आस्तै हेठ दित्ते गेदे बटन गी क्लिक करो (शुरुआत करने आस्तै इनलाइन शैलियें कन्नै छिपी दी ऐ), फ्ही बिल्ट-इन बंद बटन कन्नै इसगी खारिज करो (ते नष्ट करो)।

<div id="liveAlertPlaceholder"></div>
<button type="button" class="btn btn-primary" id="liveAlertBtn">Show live alert</button>

अस अपने लाइव अलर्ट डेमो गी ट्रिगर करने लेई निम्नलिखित जावास्क्रिप्ट दा इस्तेमाल करदे आं:

var alertPlaceholder = document.getElementById('liveAlertPlaceholder')
var alertTrigger = document.getElementById('liveAlertBtn')

function alert(message, type) {
  var wrapper = document.createElement('div')
  wrapper.innerHTML = '<div class="alert alert-' + type + ' alert-dismissible" role="alert">' + message + '<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></div>'

  alertPlaceholder.append(wrapper)
}

if (alertTrigger) {
  alertTrigger.addEventListener('click', function () {
    alert('Nice, you triggered this alert message!', 'success')
  })
}

.alert-linkकुसै बी अलर्ट दे अंदर मेल खाने आह् ले रंगीन लिंक गी जल्दी उपलब्ध करोआने लेई उपयोगिता वर्ग दा उपयोग करो .

<div class="alert alert-primary" role="alert">
  A simple primary alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
</div>
<div class="alert alert-secondary" role="alert">
  A simple secondary alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
</div>
<div class="alert alert-success" role="alert">
  A simple success alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
</div>
<div class="alert alert-danger" role="alert">
  A simple danger alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
</div>
<div class="alert alert-warning" role="alert">
  A simple warning alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
</div>
<div class="alert alert-info" role="alert">
  A simple info alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
</div>
<div class="alert alert-light" role="alert">
  A simple light alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
</div>
<div class="alert alert-dark" role="alert">
  A simple dark alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
</div>

अतिरिक्त सामग्री दी

अलर्टें च हेडिंग, पैराग्राफ ते डिवाइडर जनेह् अतिरिक्त एचटीएमएल तत्व बी होंदे न।

<div class="alert alert-success" role="alert">
  <h4 class="alert-heading">Well done!</h4>
  <p>Aww yeah, you successfully read this important alert message. This example text is going to run a bit longer so that you can see how spacing within an alert works with this kind of content.</p>
  <hr>
  <p class="mb-0">Whenever you need to, be sure to use margin utilities to keep things nice and tidy.</p>
</div>

चिह्न

इसी गै, तुस आइकनें कन्नै अलर्ट बनाने लेई फ्लेक्सबॉक्स यूटिलिटीएं ते बूटस्ट्रैप आइकनें दा इस्तेमाल करी सकदे ओ। अपने आइकनें ते सामग्री दे आधार उप्पर, तुस होर उपयोगिताएं जां कस्टम शैलियां जोड़ना चांह् दे ओ.

<div class="alert alert-primary d-flex align-items-center" role="alert">
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-exclamation-triangle-fill flex-shrink-0 me-2" viewBox="0 0 16 16" role="img" aria-label="Warning:">
    <path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/>
  </svg>
  <div>
    An example alert with an icon
  </div>
</div>

अपने अलर्टें लेई इक थमां मते आइकन दी लोड़ ऐ? होर बूटस्ट्रैप आइकनें दा इस्तेमाल करने पर विचार करो ते इक लोकल एसवीजी स्प्राइट गी इस चाल्ली बनाने पर विचार करो तां जे उस्सै आइकनें गी बार-बार आसानी कन्नै संदर्भित कीता जाई सकै.

<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
  <symbol id="check-circle-fill" fill="currentColor" viewBox="0 0 16 16">
    <path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z"/>
  </symbol>
  <symbol id="info-fill" fill="currentColor" viewBox="0 0 16 16">
    <path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/>
  </symbol>
  <symbol id="exclamation-triangle-fill" fill="currentColor" viewBox="0 0 16 16">
    <path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/>
  </symbol>
</svg>

<div class="alert alert-primary d-flex align-items-center" role="alert">
  <svg class="bi flex-shrink-0 me-2" width="24" height="24" role="img" aria-label="Info:"><use xlink:href="#info-fill"/></svg>
  <div>
    An example alert with an icon
  </div>
</div>
<div class="alert alert-success d-flex align-items-center" role="alert">
  <svg class="bi flex-shrink-0 me-2" width="24" height="24" role="img" aria-label="Success:"><use xlink:href="#check-circle-fill"/></svg>
  <div>
    An example success alert with an icon
  </div>
</div>
<div class="alert alert-warning d-flex align-items-center" role="alert">
  <svg class="bi flex-shrink-0 me-2" width="24" height="24" role="img" aria-label="Warning:"><use xlink:href="#exclamation-triangle-fill"/></svg>
  <div>
    An example warning alert with an icon
  </div>
</div>
<div class="alert alert-danger d-flex align-items-center" role="alert">
  <svg class="bi flex-shrink-0 me-2" width="24" height="24" role="img" aria-label="Danger:"><use xlink:href="#exclamation-triangle-fill"/></svg>
  <div>
    An example danger alert with an icon
  </div>
</div>

बर्खास्त करना

अलर्ट जावास्क्रिप्ट प्लगइन दा उपयोग करदे होई, कुसै बी अलर्ट गी इनलाइन गी खारिज करना संभव ऐ. इत्थें दिक्खो किस चाल्ली:

  • सुनिश्चत करो जे तुसें अलर्ट प्लगइन, जां संकलित बूटस्ट्रैप जावास्क्रिप्ट लोड कीता ऐ.
  • इक बंद बटन ते क्लास जोड़ो .alert-dismissible, जेह् ड़ा अलर्ट दे सज्जे पास्सै अतिरिक्त पैडिंग जोड़दा ऐ ते बंद बटन गी स्थिति च रक्खदा ऐ।
  • बंद बटन पर, data-bs-dismiss="alert"एट्रिब्यूट जोड़ो, जेह् ड़ा जावास्क्रिप्ट फ़ंक्शनलटी गी ट्रिगर करदा ऐ. <button>सारे डिवाइस च उचित व्यवहार आस्तै इसदे कन्नै तत्व दा इस्तेमाल करना सुनिश्चत करो .
  • .fadeउनेंगी खारिज करदे बेल्लै अलर्टें गी एनिमेट करने लेई, ते .showक्लासें गी ज़रूर जोड़ो .

तुस इसगी लाइव डेमो कन्नै एक्शन च दिक्खी सकदे ओ:

<div class="alert alert-warning alert-dismissible fade show" role="alert">
  <strong>Holy guacamole!</strong> You should check in on some of those fields below.
  <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
जदूं कोई अलर्ट खारिज कीता जंदा ऐ तां तत्व गी पृष्ठ संरचना थमां पूरी चाल्ली हटाई दित्ता जंदा ऐ। जेकर कोई कीबोर्ड बरतूनी बंद बटन दा इस्तेमाल करियै अलर्ट गी खारिज करदा ऐ तां उंदा फोकस अचानक खोह् ल्ली जाग ते ब्राउज़र दे आधार उप्पर, पृष्ठ/दस्तावेज दे शुरू च रीसेट होई जाग। इस कारण, अस अतिरिक्त जावास्क्रिप्ट गी शामल करने दी सलाह दिंदे न जेह् ड़ी closed.bs.alertघटना आस्तै सुनदी ऐ ते प्रोग्रामेटिक focus()रूप कन्नै पृष्ठ च सारें शा उपयुक्त थाह् र पर सेट करदी ऐ। जेकर तुस फोकस गी इक गैर-इंटरएक्टिव तत्व च लेई जाने दी योजना बना करदे ओ जेह् ड़ा आमतौर पर फोकस नेईं हासल करदा ऐ , तां तत्व च जोड़ना सुनिश्चत करो tabindex="-1".

सस्स

चर करने वाले

$alert-padding-y:               $spacer;
$alert-padding-x:               $spacer;
$alert-margin-bottom:           1rem;
$alert-border-radius:           $border-radius;
$alert-link-font-weight:        $font-weight-bold;
$alert-border-width:            $border-width;
$alert-bg-scale:                -80%;
$alert-border-scale:            -70%;
$alert-color-scale:             40%;
$alert-dismissible-padding-r:   $alert-padding-x * 3; // 3x covers width of x plus default padding on either side

वेरिएंट मिक्सिन

$theme-colorsसाढ़े अलर्टें लेई संदर्भ संशोधक वर्गें बनाने लेई कन्नै संयोजन च इस्तेमाल कीता जंदा ऐ।

@mixin alert-variant($background, $border, $color) {
  color: $color;
  @include gradient-bg($background);
  border-color: $border;

  .alert-link {
    color: shade-color($color, 20%);
  }
}

घरबाई

alert-variant()लूप जेह् ड़ा मिक्सिन कन्नै संशोधक वर्गें गी पैदा करदा ऐ ।

// Generate contextual modifier classes for colorizing the alert.

@each $state, $value in $theme-colors {
  $alert-background: shift-color($value, $alert-bg-scale);
  $alert-border: shift-color($value, $alert-border-scale);
  $alert-color: shift-color($value, $alert-color-scale);
  @if (contrast-ratio($alert-background, $alert-color) < $min-contrast-ratio) {
    $alert-color: mix($value, color-contrast($alert-background), abs($alert-color-scale));
  }
  .alert-#{$state} {
    @include alert-variant($alert-background, $alert-border, $alert-color);
  }
}

जावास्क्रिप्ट व्यवहार

आरंभ करना

तत्वें गी अलर्ट दे रूप च शुरू करो

var alertList = document.querySelectorAll('.alert')
var alerts =  [].slice.call(alertList).map(function (element) {
  return new bootstrap.Alert(element)
})

अलर्ट गी खारिज करने दे इकमात्र मकसद आस्तै, जेएस एपीआई दे राहें घटक गी मैन्युअल रूप कन्नै शुरू करना जरूरी नेईं ऐ. दा इस्तेमाल करने कन्नै data-bs-dismiss="alert", घटक गी स्वतः आरंभ कीता जाग ते ठीक ढंगै कन्नै खारिज कीता जाग।

होर मती जानकारी आस्तै ट्रिगर खंड दिक्खो ।

ट्रिगर करदा ऐ

अलर्ट दे अंदरdata इक बटन पर एट्रिब्यूट कन्नै बर्खास्तगी हासल कीती जाई सकदी ऐ जिसी हेठ दित्ते गेदे न:

<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>

जां अलर्ट दे बाहर इक बटन पर जि’यां एह् दिक्खेआ गेआ ऐ दा उपयोग करदे होई data-bs-target:

<button type="button" class="btn-close" data-bs-dismiss="alert" data-bs-target="#my-alert" aria-label="Close"></button>

ध्यान रक्खो जे इक अलर्ट बंद करने कन्नै एह् डीओएम थमां हटाई दित्ता जाग।

विधियां

तरीका ब्यौरा
close डीओएम थमां इक अलर्ट गी हटाइयै बंद करदा ऐ। जेकर तत्व पर .fadeते .showक्लास मौजूद न तां अलर्ट गी हटाने थमां पैह् ले फीका होई जाग.
dispose इक तत्व दी अलर्ट गी नष्ट करदा ऐ। (डीओएम तत्व पर संग्रहीत डेटा गी हटांदा ऐ)
getInstance स्थिर विधि जेह् ड़ी तुसेंगी इक DOM तत्व कन्नै जुड़ी दी अलर्ट इंस्टेंस हासल करने दी इजाजत दिंदी ऐ , तुस इसदा इस चाल्ली इस्तेमाल करी सकदे ओ :bootstrap.Alert.getInstance(alert)
getOrCreateInstance स्थिर विधि जेह् ड़ी इक DOM तत्व कन्नै जुड़ी दी इक अलर्ट इंस्टेंस रिटर्न करदी ऐ जां इक नमां बनांदी ऐ इस मामले च एह् आरंभ नेईं कीती गेई ही. तुस इसदा इस्तेमाल इस चाल्ली करी सकदे ओ:bootstrap.Alert.getOrCreateInstance(element)
var alertNode = document.querySelector('.alert')
var alert = bootstrap.Alert.getInstance(alertNode)
alert.close()

घटनाएं

बूटस्ट्रैप दा अलर्ट प्लगइन अलर्ट कार्यक्षमता च हुक करने आस्तै किश घटनाएं गी उजागर करदा ऐ।

घटना ब्यौरा
close.bs.alert closeइंस्टेंस विधि गी बुलाने पर तुरत फायर करदा ऐ।
closed.bs.alert जदूं अलर्ट बंद होई गेआ ऐ ते सीएसएस संक्रमण पूरा होई गेआ ऐ तां फायर कीता गेआ ऐ।
var myAlert = document.getElementById('myAlert')
myAlert.addEventListener('closed.bs.alert', function () {
  // do something, for instance, explicitly move focus to the most appropriate element,
  // so it doesn't get lost/reset to the start of the page
  // document.getElementById('...').focus()
})