Conceal navigation button within react-material-ui-carousel

After successfully incorporating the React Material UI carousel, I found it to be quite simple. However, one thing that eluded me was how to hide the buttons and only display them on hover. I tried setting the props navButtonsAlwaysVisible to false, but it didn't fully achieve the desired effect. Do I need to create my own logic for this or am I overlooking something?

Below is the code for the component:

import styles from '../../styles/Testimonial.module.scss'
import Image from 'next/image'
import Carousel from 'react-material-ui-carousel'

const Testimonial = _ => {
const items = [
        {
            imageUrl: "/png/image0.webp",
            feedback: "feedback0",
            name: "name0",
            location: "location0"
        },
        {
            imageUrl: "/png/image1.jpeg",
            feedback: "feedback1",
            name: "name1",
            location: "location1"
        }
    ]

    return (
        <div id="customers" className={`section ${styles.testimonial}`}>
            <h2 className={`title ${styles.title}`}>Clientes Felizes</h2>
            <span className={"separator"}> </span>

            <Carousel
                className={styles.carousel}
                autoPlay={true}
                stopAutoPlayOnHover={true}
                interval={5000}
                animation={"slide"}
                swipe={true}
                navButtonsAlwaysVisible={false}
                navButtonsProps={{ 
                    style: {
                        backgroundColor: "#8f34eb",
                        opacity: 0.4
                    }
                }} 
            >
                {
                    items.map( (item, i) => <Item key={i} item={item} /> )
                }
            </Carousel>
        </div>
    )
}

function Item(props)
{
    return (
        <article className={styles.testimonial__card}>
            <div className={styles.testimonial__photo_container}>
                <Image
                    className={styles.testimonial__photo}
                    src={props.item.imageUrl}
                    alt="Testimonial"
                    width={312}
                    height={300}
                />
            </div>
            <p className={styles.testimonial__copy}>{props.item.feedback}</p>
            <span className={styles.testimonial__name}>{props.item.name}</span>
            <span className={styles.testimonial__city}>{props.item.location}</span>
        </article>
    )
}

export default Testimonial;


Answer №1

the component includes a property named navButtonsAlwaysInvisible

navButtonsAlwaysInvisible={true}

Answer №2

To achieve your goal, you can experiment with Custom CSS. After analyzing the current rendered markup,

.jss6 {
    opacity: 0;
    transition: all ease 1000ms; /* Use a slow transition for a gradual effect */
}

You have the option to define the hover behavior for the parent element so that it only becomes visible when the parent container is hovered:

.jss1.Testimonial_carousel__3rny3:hover .jss6 {
    opacity: 1;
}

This demonstrates how it functions currently:

https://i.sstatic.net/PibHc.gif

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 reason for incorporating the footer within the container?

To see the issue in question, please visit: The footer needs to span the full width. Here is the code snippet for the page: <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div class="container"> <div c ...

Incorporating environment variables into React applications with the help of Vite

I'm currently working on a React project where I need to fetch data from a weather API. However, I've encountered an issue when trying to use the API key stored in a .env file using import.meta.env.VITE_API_KEY;. The error message states that the ...

Tips for positioning and resizing an HTML slide

Once again I am faced with my favorite HTML/CSS dilemma and am feeling frustrated. Seeking advice from the experts on SO this time around to solve my problem. Here it is... Imagine you want to create a slideshow in a browser. The requirements are simple: ...

Display a <div> element styled using CSS3

Question: I am facing a challenge with CSS3 styling. I have one class and one div. The class is currently set to display:none, but I want it to show when the mouse hovers over it (display:block). I have attempted the following: .1:hover + div#2 { dis ...

Activating Vue-Bootstrap components through an image click event in VueJS 2

Seeking to achieve: VueJS integration with Bootstrap for clickable cards I am currently working on a VueJS project where I want the cards to be clickable and reveal collapsible elements upon click. To accomplish this, I have implemented a button with the ...

The enclosed component of the withAuthenticator HOC is not receiving any props

Even though I am expecting props.onStateChange, my props object is empty. The props passed to the enclosed component of the withAuthenticator HOC are empty. import { withAuthenticator } from "@aws-amplify/ui-react"; export const App = withAuthenticator(( ...

`End session for inactive user after next authentication`

I am facing a challenge with managing inactive user sessions in my app. I tried setting the maxAge of ...nextauth to one minute and the refetch interval to 20s for SessionProvider, but encountered an issue where the session expiration on the browser cook ...

Displaying Images on top of Images with React/Javascript/NextJS

I have two images. Let's say image 1 is a thumbnail for news content. I would like to overlay a promotional PNG banner on top of this image and create a new output image. This output image will be used as the OG (Open Graph) image. How can I achieve t ...

Tips for Automatically Resizing the Input Field in React Native Gifted Chat

Having an issue with React Native Gifted Chat where the TextInput does not auto-resize when the user enters more than two lines of text or presses enter. Any solutions for this? Here's a snapshot of the problem: https://i.sstatic.net/ygX6i.jpg This ...

What is the process for updating the React version in an ASP.NET Core React/Redux template project?

Recently, I began delving into the world of React with Redux and wanted to enhance my application by incorporating Material UI for a more appealing design. To kickstart my project, I chose the React with Redux template for ASP.NET Core in Visual Studio 201 ...

Foundational 5 Grid Shuffle Shift

I am currently utilizing Foundation 5 and am aiming to create a unique DIV layout on a mobile display: -------------------- | A | -------------------- | B | -------------------- | C | -------------------- | ...

"Integrating backgrounds into divs disrupts the overall design aesthetic

One of the challenges I faced was trying to space out the three columns in my Bootstrap row while also splitting each column into two parts. After doing some research, here's the solution I came up with: <div class="container row h-100 mx-auto ...

Updating the options list of an Autocomplete component post-render: A step-by-step guide

I've encountered an issue with a function that retrieves a JSON array from a URL containing a list of options to be displayed in my Autocomplete component. function DisplayOptions() { async function GetOptions() { options_list = await fetc ...

Resolving the Material-UI NextJS Button Styling Dilemma

I've encountered an issue with the styling of a few buttons in JS. When I apply a styling class using className, the formatting works fine on the initial render but loses its styling on subsequent refreshes. This problem is specific to two individual ...

Tips on customizing the appearance of JavaScript output?

I recently created a plugin for my website with JavaScript, and one of the lines of code I used was output.innerHTML = "Test"; Is it possible to apply CSS styles to this element, or is there an alternative method? ...

Is it necessary to have CSRF tokens post logging in?

I am working on a basic to-do list application that requires users to log in with a csrf-token before adding items to their list. Do I need to include csrf_tokens in the AJAX submissions for todo list items once the user is already logged in? The authent ...

Toggle dark mode in child Layout component with React and Material-UI

Trying to incorporate a dark mode switch in a React+MUI (JS) layout component has been quite challenging. I have been struggling to find a solution using states for this feature. The main goal is to toggle between light and dark modes by utilizing a switch ...

Injecting personalized themes into withStyles

I've designed a theme that I'm attempting to incorporate into my useStyles. Here's the theme: import { createMuiTheme } from "@material-ui/core/styles"; const customTheme = createMuiTheme({ palette: { primary: { ...

React wrapper for user input

I need help creating a form for user data using React components. Specifically, I am struggling with passing the handler to the input component. Here is my current form setup: import React from 'react'; import {addUser as addNewUser} from ' ...

FlexNav excluding

I have implemented FlexNav for my website navigation. The demo I used sets the width of top-level menu items to 20%, which works well with five menu items. .flexnav li { . . . width: 20%; } However, in my menu, the text lengths of the top ...