मुखेल आशयाचेर वचचें डॉक्स नेव्हिगेशनाचेर वचचें
Check
in English

सावधानताय दिता

उपलब्ध आनी लवचीक सावधानताय संदेशांच्या मुठींतल्यान सादारण वापरप्याच्या कृतीं खातीर संदर्भ प्रतिसाद संदेश पुरवण करात.

उदाहरणां

खंयच्याय मजकूर लांबाये खातीर सावधानताय उपलब्ध आसात, तशेंच पर्यायी बंद बटण. योग्य स्टायलिंग खातीर, आठ गरजेच्या संदर्भ वर्गांतलो एक वापरात (देखीक, .alert-success). इनलायन डिसमिस करपाखातीर, सावधानताय वापरात JavaScript प्लगइन .

एचटीएमएल हें नांव
<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>

आमचो लायव्ह इशारो डेमो ट्रिगर करपाक आमी सकयल दिल्ले जावास्क्रिप्ट वापरतात:

const alertPlaceholder = document.getElementById('liveAlertPlaceholder')

const alert = (message, type) => {
  const wrapper = document.createElement('div')
  wrapper.innerHTML = [
    `<div class="alert alert-${type} alert-dismissible" role="alert">`,
    `   <div>${message}</div>`,
    '   <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>',
    '</div>'
  ].join('')

  alertPlaceholder.append(wrapper)
}

const alertTrigger = document.getElementById('liveAlertBtn')
if (alertTrigger) {
  alertTrigger.addEventListener('click', () => {
    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>

अतिरिक्त आशय

तशेंच सावधानतायांत शीर्षकां, परिच्छेद आनी विभाजक अशे अतिरिक्त HTML घटक आसूं येतात.

एचटीएमएल हें नांव
<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>

चिन्नां

तेच प्रमाणें, चिन्नां सयत सावधानताय तयार करपाक तुमी flexbox उपयुक्तताय आनी बूटस्ट्रॅप चिन्नां वापरूं येतात. तुमच्या चिन्नां आनी सामुग्रीचेर आदारून, तुमकां चड उपयुक्तताय वा सानुकूल शैली जोडूंक जाय आसतली.

एचटीएमएल हें नांव
<div class="alert alert-primary d-flex align-items-center" role="alert">
  <svg xmlns="http://www.w3.org/2000/svg" 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 स्प्राइट अशे तरेन करपाचो विचार करात जेणे करून सहजपणान त्याच चिन्नांचो परत परत संदर्भ दिवचो.

एचटीएमएल हें नांव
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
  <symbol id="check-circle-fill" 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" 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" 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" 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" 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" 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" 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>
जेन्ना इशारो खारिज जाता, तेन्ना घटक पान रचणुकेंतल्यान पुरायपणान काडून उडयतात. कीबोर्ड वापरपी बंद बटण वापरून इशारो न्हयकारल्यार, तांचें लक्ष अचकीत वचतलें आनी, ब्राउझराचेर आदारून, पान/दस्तावेजाच्या सुरवातीक रिसेट जातलें. ह्या कारणा खातीर, आमी अतिरिक्त JavaScript समाविष्ट करपाची शिफारस करतात जी closed.bs.alertघडणुके खातीर आयकता आनी प्रोग्रामेटिक focus()रितीन पानांतल्या सगळ्यांत योग्य सुवातेर सेट करता. सामान्यपणान फोकस मेळना अशा बिगर-परस्परक्रियाशील घटकाचेर तुमी फोकस व्हरपाची येवजण करता जाल्यार, tabindex="-1"घटकांत जोडपाची खात्री करात.

सीएसएस हें नांव

चड-उणें

v5.2.0 त जोडलां

Bootstrap च्या विकसीत जावपी CSS चड-उणें पद्दतीचो एक भाग म्हूण, आतां सावधानताय .alertवाडयल्ल्या रियल-टायम पसंतीखातीर थळाव्या CSS चड-उणें चालू वापरतात. CSS चयापचयांखातीर मोलां Sass वरवीं सेट केल्लीं आसात, देखून Sass पसंतीचें अजूनय समर्थीत आसा, तेंय.

  --#{$prefix}alert-bg: transparent;
  --#{$prefix}alert-padding-x: #{$alert-padding-x};
  --#{$prefix}alert-padding-y: #{$alert-padding-y};
  --#{$prefix}alert-margin-bottom: #{$alert-margin-bottom};
  --#{$prefix}alert-color: inherit;
  --#{$prefix}alert-border-color: transparent;
  --#{$prefix}alert-border: #{$alert-border-width} solid var(--#{$prefix}alert-border-color);
  --#{$prefix}alert-border-radius: #{$alert-border-radius};
  

सॅस चड-उणें

$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) {
  --#{$prefix}alert-color: #{$color};
  --#{$prefix}alert-bg: #{$background};
  --#{$prefix}alert-border-color: #{$border};

  @if $enable-gradients {
    background-image: var(--#{$prefix}gradient);
  }

  .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);
  }
}

जावास्क्रिप्ट वागणूक

आरंभ करप

घटकांक सावधानताय म्हणून आरंभ करात

const alertList = document.querySelectorAll('.alert')
const alerts = [...alertList].map(element => new bootstrap.Alert(element))

इशारो न्हयकारपाच्या एकमेव उद्देशा खातीर, JS API वरवीं घटक हाताळणीन आरंभ करपाची गरज ना. चो वापर करून 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>

लक्षांत दवरात की इशारो बंद केल्यार तो DOM वयल्यान काडून उडयतलो.

पद्दती

तुमी सावधानताय कंस्ट्रक्टरा वांगडा इशारो दृष्टांत तयार करूंक शकतात, देखीक:

const bsAlert = new bootstrap.Alert('#myAlert')

data-bs-dismiss="alert"हाका लागून गुणधर्म आशिल्ल्या वंशज घटकांचेर क्लिक घडणुको आयकूंक एक इशारो करता . (डेटा-एपीआयचें ऑटो-इनिशियलायझेशन वापरतना गरजेचें ना.)

पद्दत वर्णन
close DOM वयल्यान काडून एक इशारो बंद करता. .fadeघटकाचेर and वर्ग हाजीर आसल्यार .show, तो काडचे पयलीं इशारो फीको जातलो.
dispose एका घटकाची सावधानताय नश्ट करता. (DOM घटकाचेर सांठयल्लो डेटा काडून उडयता)
getInstance स्थिर पद्दत जी तुमकां DOM घटकाकडेन संबंदीत आशिल्ली सावधानताय दृष्टांत मेळोवपाक परवानगी दिता. देखीक: bootstrap.Alert.getInstance(alert).
getOrCreateInstance स्थिर पद्दत जी DOM घटकाक संबंदीत आशिल्ली सावधानताय दृष्टांत परत दिता वा ती आरंभ करूंक नाशिल्ल्या प्रकरणांत नवी तयार करता. तुमी ताचो वापर अशे तरेन करूंक शकतात: bootstrap.Alert.getOrCreateInstance(element).

मुळावो वापर: १.

const alert = bootstrap.Alert.getOrCreateInstance('#myAlert')
alert.close()

घडणुको

Bootstrap चें सावधान प्लगइन सावधान कार्यक्षमतेक हुक करपा खातीर कांय घडणुको उक्ती करता.

प्रसंग वर्णन
close.bs.alert closeदृष्टांत पद्दत आपयल्यार रोखडीच फायर करता .
closed.bs.alert इशारो बंद जातकच आनी CSS संक्रमण पुराय जातकच फायर केला.
const myAlert = document.getElementById('myAlert')
myAlert.addEventListener('closed.bs.alert', event => {
  // 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()
})