React-Accessible-Accordion is not displaying the toggle icon

I have integrated React-accessible-accordion into my React application. The click functionality is working correctly, but I am facing an issue with the arrow icon not appearing on the accordion. Upon comparing my DOM structure with the example provided in npm, it seems that the div for the icon itself is missing from my DOM.

Here is a snippet of my code:


import React from 'react';
import ReactDOM from 'react-dom';

import {
    Accordion,
    AccordionItem,
    AccordionItemTitle,
    AccordionItemBody,
} from 'react-accessible-accordion';

import 'react-accessible-accordion/dist/fancy-example.css';
import 'react-accessible-accordion/dist/minimal-example.css';

<div className="container">
    <Accordion>
        <AccordionItem>
            <AccordionItemTitle>
                <h4>Hello, This is me..</h4>
            </AccordionItemTitle>
            <AccordionItemBody>
                Some Text
            </AccordionItemBody>
        </AccordionItem>
    </Accordion>
</div>

The arrow icon should come from this line of code:

<div class="accordion__arrow" role="presentation"></div>

I noticed that this specific div is not being added to my elements. Could this be due to a missing line like

document.querySelector('[data-mount]')
? Should I include this to ensure the arrow icons are loaded? It's strange because the examples on npm show these icons in each accordion section.

For reference, here is the link I looked at - npm react-accessible-accordion

Answer №1

Have you added the CSS style sheet correctly?

// Make sure to import the necessary styles for the accordion component.
import 'react-accessible-accordion/dist/fancy-example.css';

Answer №2

By including the code snippet below in AccordionTitle, the problem is resolved:

<h3 className="u-position-relative"> 
Accessible Accordion 
<div className="accordion__arrow" role="presentation"/> 
</h3>

Answer №3

To get this working, follow these steps:

1] Begin by copying all the contents of the file 'react-accessible-accordion/dist/fancy-example.css' into a new file, as we will be modifying some classes.

2] Insert a div in the AccordionItemTitle component

    <AccordionItemTitle>
        <h4>Hello, This is me..</h4>
        <div className="accordion__arrow" role="presentation" />
    </AccordionItemTitle>

3] Add the following styles to the stylesheet you just created:

.accordion__item {
    position: relative;
}
.accordion__arrow {
    display: inline-block;
    width: 24px;
    height: 12px;
    position: absolute;
    top: 40px;
    right: 15px;
    margin-top: -6px;
}

Once you've completed these steps, the toggle button should appear as intended.

Answer №4

insert this block of code

<AccordionItemTitle>
    <h3 className="u-position-relative">
             Accessible Accordion
        <div className="accordion__arrow" role="presentation" />
    </h3>
</AccordionItemTitle>

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

I am experiencing an issue where the button in express is not functioning as expected, and I am not

Currently, I am diving into learning express node.js. I've been working on a simple calculator code, but whenever I press the button, I do not receive any response back. Strangely, there are no errors showing up in my code either. I seem to be at a lo ...

Encountered an error while attempting to minify code during the npm run build

After completing my react application using create-react-app , I encountered an issue when trying to build it with npm-build. While there were no problems running it locally with npm start, I faced an error during minification of the code. I attempted ...

What is a Mongoose Schema type in TypeScript and how can it be used as a custom

https://i.stack.imgur.com/mtlRi.png Could anyone assist me with storing a custom object that includes attributes from the StationRating interface? ...

Expanding a non-bootstrap navigation bar upon clicking the menu

I'm having some difficulty getting my navigation menu to show up when I click the navigation menu icon. HTML nav role="navigation" class="navbar"> <div class="nav-header"> <a href="#"><span style="font-family: 'Cab ...

Using Vue.js for redirecting with a post method

Is there a way to redirect from Vue.js to a Laravel controller using the POST method without using AJAX? I would like to be able to use var_dump or dd inside the controller. //Vue.js axios.post('/add-hotel-listing', this.finish).then((respons ...

Customizing Material-UI Select Styles

I have been attempting to customize the appearance of Material-UI's <Select> component with variant="outlined". In this particular scenario, my objective is to hide the dropdown icon and set padding-right to 0px. Based on my interpretation of t ...

Bullet points colliding with one another

Is there a way to display an unordered list with list items in two rows and multiple columns without the bullet points overlapping? I have tried adjusting margins, but is there a more elegant solution to this issue? The requirement is to maintain the bul ...

Is the height set to auto for the image stretching to equal the height of the PNG file?

.q-team-images { width: 6.4rem; height: auto; padding-bottom: 1rem; } Does the CSS styling mentioned above ensure that the image will adjust its height according to the height of its PNG file? ...

"A common error in Node Express occurs when 'res.send' is mistakenly used within middleware and triggers the message 'res.send

Here is a snippet of my code: const customMiddleware = () => { return (req, res, next) => { ... console.log(res);// this only displays the locals set in a previous middleware res.send('not working');//send is not a function ...

Error: The variable "phone" has not been declared

I am working on creating clients. Requests are coming in from the front end as an array containing multiple clients with information like fullName and phone number. I am trying to iterate over this array in order to create these clients in MongoDB by using ...

Hidden overflow and identification in URL causes content to be invisible and suddenly appear at the top of the page

I'm encountering a strange issue with containers that have overflow:hidden and when the page URL includes an id. The content gets pushed up and becomes invisible. This problem arises when I apply padding and negative margin at the bottom to create equ ...

Adjust the color of additional SVG paths upon hovering

I have the following code snippet. .icon {stroke-width: 0; stroke: currentColor; fill: currentColor;} a {color: red} a:hover {color: pink} a:hover circle {fill: green !important; color: orange} a:hover path {fill: blue !important} <a href=""> ...

Creating an Image slideShow with only one Image - making it slide on itself

Apologies for this confusing and vague question. Imagine I only have a single image, and I want to create a slideshow using technologies like Angular, jQuery, JavaScript, or just CSS. What I am aiming for is when the user clicks on my slide button, the i ...

Optimal location for loading data in a connected redux component

When it comes to loading data in a redux component, where is the most appropriate place to do so? Currently, my implementation looks like this: Let's assume I have this container component: import { loadResultsPage } from '../actions/winratio- ...

There was an issue with executing the postinstall command: [email protected] postinstall: `node --harmony ./postinstall.js Exit status

Having trouble installing ejs using npm on my computer. I keep getting an error message and can't seem to get ejs installed. Any assistance would be greatly appreciated. https://i.sstatic.net/PxEGj.png ...

Error: The Moongoose JS Schema is not recognized as a constructor or function

I am encountering an issue with Mongoose.js Below is my Node.js code: var mongoose=require('moongoose'); var test=mongoose.Schema({test:String}) module.exports = mongoose.model('test',test); Upon executing this code, I receive the fo ...

"Prisma vs. Supabase: A Comparison of Image Uploading

I am encountering an issue with adding image URLs to the Prisma database. I have successfully uploaded multiple images from an input file to Supabase storage, but when I try to add their URLs to the database, I receive an error regarding property compatibi ...

Encountering a GraphQL error during the compilation process

I've been following along with this informative tutorial: https://www.gatsbyjs.org/blog/2017-07-19-creating-a-blog-with-gatsby/ After completing all the steps, I encountered a GraphQL compile error: GraphQL Error There was an error while compiling y ...

Attempting to customize the appearance of a submit button independently from other input elements

Hey there, I have a question that might sound silly, but bear with me as I'm still learning CSS. I've been experimenting with CakePHP and its form helper to create a form. Here's a snippet of the code I'm working with: <p><?ph ...

Struggling to share information across components in React

I am currently working on developing a Weather app to enhance my React skills, but I am facing some challenges. You can access the code I have written here: Codesandbox My project consists of 3 components: Form.jsx Weather.jsx WeatherDetail.jsx Weather. ...