Customizing the scrollbar within a modal using reactjs-popup

I am currently working on a CustomPopup functional component that includes a reactjs-popup:

function CustomPopup({setFalse, item}){return(<Popup open={true} onClose={() => {setFalse(false)}} modal closeOnDocumentClick nested>
{item === "howto" ?
(close => (
  <div className="modal">
    <button className="close" onClick={close}>
      &times;
    </button>
    <div className="header"> HowTo </div>
    <div className="content">
      {'howto'}
      Lorem ipsum dolor sit amet consectetur adipisicing elit. Atque, a nostrum.
      Dolorem, repellat quidem ut, minima sint vel eveniet quibusdam voluptates
      delectus doloremque, explicabo tempore dicta adipisci fugit amet dignissimos?
      <br />...

https://i.stack.imgur.com/nL1T8.png

I have been trying to change the style of the scrollbar within the popup, but so far, none of the methods I attempted have worked.

My attempts included:

...applying styles inside the modal and modal-content classes:

.modal > .content {
width: 100%;
padding: 10px 5px;
height: 750px;
overflow-y: scroll;
scrollbar-color: #6969dd}

...using a universal selector:

*{
  scrollbar-color: #6969dd #e0e0e0;
  scrollbar-base-color: #6969dd;
  scrollbar-face-color: #6969dd;
  scrollbar-track-color: #6969dd;
  scrollbar-gutter: #6969dd;
}

...attempting with webkit properties:

.modal::-webkit-scrollbar {
    width: 12px;               /* width of the entire scrollbar */
  }
  
  .modal::-webkit-scrollbar-track {
    background: orange;        /* color of the tracking area */
  }
  
  .modal::-webkit-scrollbar-thumb {
    background-color: blue;    /* color of the scroll thumb */
    border-radius: 20px;       /* roundness of the scroll thumb */
    border: 3px solid orange;  /* creates padding around scroll thumb */

I have tested these in both Edge and Chrome browsers without success. Any new suggestions would be greatly appreciated.

Answer №1

For your Pop-up component, simply enclose it in a div tag and add the following styling to your main CSS file:

div::-webkit-scrollbar-track {
box-shadow: inset 0 0 6px #f8fbff;
border-radius: 5px;
 }

div::-webkit-scrollbar-thumb {
background-color: #9fa9bd;
border-radius: 5px;
}
div::-webkit-scrollbar {
width: 0.5em;
border-radius: 5px;
}

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

Steps to update an object in a react hooks project using axios and a json server

I have implemented a dialog box within a table to enable editing of rows using an axios.patch request. However, I am facing an issue where the values of the row are displayed in TextFields inside the dialog box but cannot be updated. Can anyone provide ass ...

Efficiently centering content in a grid layout using automatic fit repetition for optimized responsiveness

I've implemented a responsive grid where each item has its own hidden details section that is revealed upon clicking the item. The structure of the HTML/CSS setup is as follows: <div class="grid"> <div class="item"> ...

Guide to implementing onClick event on options within Autocomplete Component(Material UI)

I have been trying to figure out how to add an onClick event to the options in my autocomplete search functionality. I want the selected option to redirect somewhere when clicked, rather than just populating a search field or text box. Despite searching ...

Integrate your React Native application with a Node.js backend on your local machine

My attempt to establish a connection between my react native app and my node.js app on a Windows system has hit a roadblock. While I am able to receive responses from the node API using Postman, the response from the react native app is coming back as unde ...

Receive fresh properties in React and subsequently reset state

I need some guidance on this issue: My scenario involves a parent React component and its child. The parent component contains a table, while the child has its own controls. What I am trying to achieve is the ability to click on a cell within the parent&a ...

Top solution for maintaining smooth navigation across web pages

As I dive into the world of web development, I find myself intrigued by the idea of reusing navigation and banners across multiple web pages. However, despite my research efforts, I have yet to come across a definitive answer. My objective is simple: The ...

Display the content of an md-dialog with a scroll bar

I am experiencing a problem with printing a long report created using md-list displayed in a md-dialog. When I attempt to print it, only the section that is currently visible on the screen gets printed instead of the entire length of the md-list. I have at ...

Struggling to align the header of a column to the center in a mat-table that is sortable?

I am working with a mat-table that has a sortable column similar to the example shown here, but I am having trouble centering the column headers using my CSS file. Interestingly enough, I am able to achieve this when making changes in the browser debugger! ...

Having trouble registering an uninstalled web hook in a Shopify React app

// I encountered an issue when trying to register an uninstalled app webhook. The code I have used for registering other hooks is functioning correctly, but I am facing an error specifically with the uninstalled webhook registration. const registrationU ...

Encountering error #426 in NextJs when the app is loaded for the first time in a new browser, but only in a

Encountering a strange error exclusively in production, particularly when loading the site for the first time on a new browser or after clearing all caches. The website is built using nextjs 13.2.3 and hosted on Vercel. Refer to the screenshot below: http ...

Is there a way to configure a Mui textfield to only allow numeric input? It currently accepts numbers, the letter "e," and dashes

Take a look at my current code. <TextField error={values[1].error} fullWidth id="id" type="number" value={values[1].Id} placeholder='Enter ID' onChange={handleChange(1,'Id')} variant="outlined" inputProps={{min: 0,inputMode: &apos ...

Tips for keeping Input field in focus while popper is displayed in Material-UI

I would like to implement Accept and Reject buttons on input fields that only appear when the user has focused on the input fields, similar to the functionality in Jira. I attempted to create a similar component using material-ui. However, I encountered a ...

Tips for avoiding content appearing beneath overlapping elements

I am facing an issue with a hero image that has an overlapping box. I want to add content below the box but it ends up appearing behind the box. How can I ensure that the content shows below the box while maintaining responsiveness? .shell { display: ...

The concept of unassigned properties in React ES6

As a newcomer to React, I am attempting to utilize props following an online tutorial. However, I have encountered an undefined error at the bottom of my code. Is there a solution to this issue? import React, { useEffect, useState } from 'react' ...

Troubleshooting problem with Angular 2 in Internet Explorer related to the use of [style]="

I've encountered a challenge while using angular 2 (2.0.0-beta.17). The app works perfectly on most browsers, but as expected, IE 11 is causing trouble. The scripts included in the head for angular are: <script type='text/javascript' sr ...

Arrange the row information in the MUI DataGrid in order to prepare it for exporting to CSV or Excel

Is there a way to organize row data for exporting to CSV or Excel with the MUI DataGrid? Take a look at my code snippet for the toolbar. slots={{ noRowsOverlay: NoDataComponent, noResultsOverlay: NoDataComponent, toolbar: ( ...

Whiskey Angostura and Straight Row Set to 8, not 12

Recently, I incorporated Bourbon, Bitters, and Neat into my rails application. However, I am encountering an issue where the number of grid-columns is stuck at 8 instead of the desired 12. To address this problem, I have taken the following steps: Ensur ...

Implementing nested routes in React while hosting with IIS

My React SPA is served through IIS, with the build results uploaded to a specific directory. When trying to access the URL http://example.com/About directly or refreshing the page, a 404 error was returned. After some investigation, I found that adding th ...

Relocate the HTML checkbox to the left side of its width

I need an answer that utilizes only CSS, without any JavaScript. In a form, I have a checkbox as follows: <label for="autologin">Remember Me</label> <input type="checkbox" class="checkbox" id="autologin" name="autologin" value="1"> <d ...

How can I combine my Authorization Header with httpLink in Apollo Client and Next Js?

I've been developing an application that requires authentication to create posts. To achieve this, I created two objects - httpLink (connecting to the backend) and authLink (handling the passing of headers in the form of a Bearer token). Below is a s ...