question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Offcanvas not showing with class .show

See original GitHub issue

Hi all,

I’m trying to use the offcanvas opened by default but adding the class .show is not working (it is closed as default). Using these versions: https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/js/bootstrap.bundle.min.js

<div class="offcanvas offcanvas-start show" data-bs-scroll="true" tabindex="-1" id="offcanvas" data-bs-backdrop="false" aria-labelledby="offcanvasNavbarLabel" style="width:300px;">
	<div class="offcanvas-header">
		<a href="/">
			<img src="assets/logo.png" alt="Logo">
		</a>
		<button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button>
	</div>
	<div class="offcanvas-body">
	</div>
</div>

Adding on the style “visibility:visible;” starts showing by default but the buttons for dismiss and toggle seems not working on the first click.

Using it inside the main navbar (exactly as the example provided on the docs).

Am I missing something? Could you help, please?

  • Windows 10
  • Edge latest version

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
recursivecodescommented, Sep 8, 2021

Thanks!

1reaction
GeoSotcommented, Sep 8, 2021

new bootstrap.Offcanvas(document.getElementById(‘offcanvasTop’)).hide() Try:


bootstrap.Offcanvas.getOrCreateInstance('#offcanvaTops').hide()

Your example works on codepen but not on my environment.

I managed to find windows 10 with Edge latest version. Unfortunately, I successfully opened codepen example, plus a demo of the same code , as an html file. So I do not know how to help you, without replicating it

Read more comments on GitHub >

github_iconTop Results From Across the Web

v5 Offcanvas: Not visible on page load with show class
I'm trying out the new offcanvas component, which is great, but when I have show as part of the initial classes, the menu...
Read more >
Bootstrap 5 offcanvas is not working with images or icons ...
Bootstrap 5 offcanvas is not working with images or icons inside the anchor · Go on your mobile device · Go to the...
Read more >
Offcanvas
Build hidden sidebars into your project for navigation, shopping carts, and more with a few classes and our JavaScript plugin.
Read more >
[Solved] Off Canvas Menu-Header Not Showing - Forums
Got issue with my off canvas responsive. When it reaches my breakpoints of 959px my menu header will not show its background?
Read more >
Bootstrap 5 Offcanvas
Offcanvas. Offcanvas is similar to modals (hidden by default and shown when activated), except that is often used as a sidebar navigation menu....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found