Accordion suddenly shuts after opening in tailwind css design

I recently came across this unique accordion design:

<div class="accordion-item mb-5 overflow-hidden rounded-lg border border-jacarta-100 dark:border-jacarta-600">
    <h2 class="accordion-header" id="faq-heading-1">
        <button class="accordion-button relative flex w-full items-center justify-between bg-white px-4 py-3 text-left font-display text-jacarta-700 dark:bg-jacarta-700 dark:text-white" type="button" data-bs-toggle="collapse" data-bs-target="#faq-1" aria-expanded="false" aria-controls="faq-1">
            <span>Exploring the world of tax and legal advisory</span>
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" class="accordion-arrow h-4 w-4 shrink-0 fill-jacarta-700 transition-transform dark:fill-white">
            <path fill="none" d="M0 0h24v24H0z"></path>
            <path d="M12 13.172l4.95-4.95 1.414 1.414L12 16 5.636 9.636 7.05 8.222z"></path>
            </svg>
        </button>
    </h2>
    <div id="faq-1" class="accordion-collapse" aria-labelledby="faq-heading-1" data-bs-parent="#accordionFAQ">
        <div class="accordion-body border-t border-jacarta-100 bg-white p-4 dark:border-jacarta-600 dark:bg-jacarta-700">
            <p class="dark:text-jacarta-200">Learn how to enter the fascinating world of NFT creation and collection building. Absolutely innovative.
            </p>
        </div>
    </div>
</div>

Upon closely examining the design, I noticed that the item closes immediately after it opens:

https://i.sstatic.net/F3j5a.png

The desired expectation was something like this:

https://i.sstatic.net/i0uAq.png

Further investigation revealed that disabling specific CSS properties via browser inspector provided the desired outcome:

https://i.sstatic.net/px2ut.png

However, there seems to be an issue where the collapse class is added twice when toggling the accordion. This raises questions about the CSS being present in both a stylesheet and inline. With only one file available, how can the accordion button be fixed?

Answer №1

An issue arises due to tailwind incorporating the collapse property which needs to be left empty. More details can be found in this reference link:

https://github.com/tailwindlabs/tailwindcss/issues/9663

For a temporary fix, follow these steps:

  1. Add this property to tailwind.config.js file:

    corePlugins: {
      visibility: false
    },

  1. In src/css/style.css, include the following code:

@layer utilities {
  .visible {
    visibility: visible;
  }
  .invisible {
    visibility: hidden;
  }
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best method for showcasing two images side by side in a column layout?

I need to showcase 2 images in a row using AngularJS, with the next two images in the following row and so forth. Img1 Img2 Img3 Img4 This is my code: <section id="content"> <div class="content-wrap"> <div class="container clearfix "& ...

Is there an easy method for customizing scrollbars?

I'm looking to include an "overflow:scroll" in a navigation div, but the default scrollbar on windows is unattractive. Is there a simple way to customize the scrollbar without having to download extra JavaScript libraries, APIs, and so on? ...

Ways to reduce the size of the border on the bottom in HTML/CSS

Currently, I am working with a div container (utilizing bootstrap.min.css) that contains another class called divborder. The length of the border-bottom in divborder is quite long and I'm wondering how I can adjust it to be shorter. Below is a snippe ...

How to completely color a div in CSS

<h:head> <title>Unique Title</title> <style> .top{ margin: 0; padding: 0; background-color: blue; height: 15px; width: max-content; } </style ...

Angular 8 ngBootstrap - Resizable and Draggable Modal Feature

Currently, I am attempting to integrate Bootstrap version 4 with Angular 8. My main goal is to create a modal that is both re-sizable and draggable. Although there are some examples available for other versions such as 3.xx, none seem to be specifically de ...

Begin the jQuery ResponsiveSlides Slider with the final image in the <ul> list

Currently utilizing the responsiveSlides image slider from responsiveSlides on our website. This jQuery slider uses an HTML unordered list of images to slide through automatically. The issue I'm facing is that before the slider actually starts (meani ...

Make the text stand out by highlighting it within a div using a striking blue

Currently, I am working with Angular2 and have incorporated a div element to display multiple lines of text. Positioned below the text is a button that, when clicked, should select the entirety of the text within the div (similar to selecting text manually ...

What is the best way to show an image behind text as a background?

I'm seeking a way to have text displayed over an image without the need to create a new image every time the text changes. Currently, I achieve this using Photoshop, but it requires manual updates each time the text is modified. I am looking for a sol ...

Tips on designing checkboxes with CSS

Can someone help me figure out how to style a checkbox using the code below? <input type="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;" /> I've tried applying this style but it doesn't seem to work. The chec ...

When my screen measures 1700px wide, a width of 100% in CSS appears significantly narrower than a width of 500px

Currently, I am working on designing a responsive layout for a 3D globe. The code snippet that stores the structure is as follows: <div class="text-center main"> <canvas id='globe' width='100%' height='100%'> ...

The latest bug fix and update in Bootstrap 4.5.2 now includes an updated version of Popper.js. Make sure to use the

Hello fellow developers, I am currently working with npm bootstrap version 4.5.2 and above. However, I am facing an issue with the compatibility of @popperjs/core. If anyone can assist me in resolving the bootstrap.js error temporarily, specifically re ...

Is there a method for responding to the user's zoom action?

Have you noticed the sliding effect on Apple's website when zooming in and out? Check it out here: sbsstatic/maintenance.html?start=0&tstart=0">https://discussions.apple.com/sbsstatic/maintenance.html?start=0&tstart=0 It seems like the top ...

How to Change Background Color to Black for a PNG Image Using CSS in Ionic

When applying CSS in Ionic, I encountered an issue with the background image causing the background to turn black. Without the image, everything looks fine. ion-content { --background: url("/assets/product_background.png") 0 0/100% 95% no-re ...

Tips for aligning an image to the left inside a paragraph

Currently working on my ecommerce store homepage, placed just below the carousel is an image with the heading "I Wish I Were Knitting..." accompanied by a paragraph that seems to be wrapped around it. I have added a float class to the image tag within the ...

Utilize express middleware for applying CSS styles in web development

How's it going? I've been experimenting with middleware in Express JS, like this: app.get ('/user/:school/:dual', function (req, res, next) {   ......   ...   ...... }); Everything seems to be working fine so far. But when I na ...

Utilize the nth-child() selector to style list items within a specific tag

How can I style li tags using nth-child when these li tags are nested within a tag like this: <ul> <a href=""><li>this is a test</li></a> <a href=""><li>this is a test</li></a&g ...

Text will be positioned between the Header and Footer

The text positioned between the header and footer elements is flowing beneath them. I attempted to use flex-start and flex-end on both the header and footer, but they do not align to the absolute top. Instead, they are positioned above and below the conten ...

Is there a way to extract the ID or other attributes from a clicked element using AMP HTML and incorporate them to generate a URL for an anchor tag?

I have a collection of checkboxes, each with its own unique ID. When a checkbox is clicked, I need to extract the ID and generate a string like '/some/path/?myids=checkOne,checkTwo' (where checkOne and checkTwo are IDs of two different checkboxes ...

Struggling to grasp the alignment of Bootstrap Grids across different screen dimensions

After coming across a code snippet on codeply.com, I decided to modify it slightly in order to gain a better understanding of how col-xl, col-lg, col-sm, and col-xs work together. Here is the code snippet that I found: As a newcomer to Bootstrap, I am uns ...

The importance of formatting in coding and how to effectively apply it

Why is proper code formatting so important for programmers? What are the benefits of following consistent formatting rules, and what exactly are these rules? Many programmers prefer to write their code like this: <html> <head> < ...