Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alerts with dark background #1012

Merged
merged 4 commits into from
Feb 22, 2022
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions site/content/docs/5.1/components/alerts.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,31 @@ You can see this in action with a live demo:
When an alert is dismissed, the element is completely removed from the page structure. If a keyboard user dismisses the alert using the close button, their focus will suddenly be lost and, depending on the browser, reset to the start of the page/document. For this reason, we recommend including additional JavaScript that listens for the `closed.bs.alert` event and programmatically sets `focus()` to the most appropriate location in the page. If you're planning to move focus to a non-interactive element that normally does not receive focus, make sure to add `tabindex="-1"` to the element.
{{< /callout >}}

### Dark background
julien-deramond marked this conversation as resolved.
Show resolved Hide resolved

To get the inverted alert behavior, simply add `.bg-dark` class to your alert.
julien-deramond marked this conversation as resolved.
Show resolved Hide resolved

Change the default `.btn-close` to be white by adding the `.btn-close-white` class.

{{< example class="bg-dark" >}}
<div class="alert alert-success bg-dark" role="alert">
<span class="alert-icon"><span class="visually-hidden">Success</span></span>
<p>Success notification text goes here.</p>
</div>
<div class="alert alert-success bg-dark" role="alert">
<span class="alert-icon"><span class="visually-hidden">Success</span></span>
<div>
<h4 class="alert-heading">Success notification text with <a href="#">a link</a> goes here.</h4>
<p>Description text with <a href="#">a link</a> goes here.</p>
</div>
</div>
<div class="alert alert-warning alert-dismissible fade show bg-dark" role="alert">
<span class="alert-icon"><span class="visually-hidden">Warning</span></span>
<p>Warning notification text goes here.</p>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="alert"><span class="visually-hidden">Close</span></button>
</div>
{{< /example >}}

## CSS

<small class="d-inline-flex px-2 py-1 font-monospace text-muted border rounded-3">Added in v5.2.0</small>
Expand Down