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

Issue with Mui PaginationItem not syncing properly across multiple components

Hey there! I have set up Pagination and PaginationItem from MUI in my project. <Stack> <Pagination count={count} renderItem={(item) => ( <PaginationItem className="pagination" components={{ previ ...

Experimenting with TypeScript asynchronous functions, the async callback was not triggered despite being called within the .then() method

After extensively searching for a solution, I have been unable to find one. The only possibility that comes to mind is that redux-mock-store does not support Promises. Below is the test method in question. import thunk from 'redux-thunk'; impor ...

Create a CSS style to set the background with a half height positioned behind the

I am looking to create a div with a background and overlay effect. Here is what I have done so far: I want it to look like this: body { background: blue; } .wrap { height: 300px; width: 600px; margin: 0 auto; background-color: #000000; } .b ...

What is the best way to target an anchor element that includes a particular word using jquery or css?

I attempted $('a[title="*"]').find('contains("PDF")').css({'background-color':'red'}); Unfortunately, this code is not working as expected. To clarify, I am searching for a specific word in the title. ...

Is it possible to utilize router.push within Redux thunk? Is this considered a beneficial approach?

I have this anchor element: <a className="btn btn-sm btn-circle" href={`https://www.facebook.com/sharer/sharer.php?u=${ process.env.NEXT_PUBLIC_ENVIRONMENT == "prod" ? "https://tikex.com" : "https:/ ...

What is the best way to add padding between form elements in Bootstrap 4?

Is there a way to add space between form elements in Bootstrap 4? The code snippet below shows an example where the full name has spacing from '@' but the username does not have any. Any suggestions on how to fix this? <form class="form-inlin ...

Placing a crimson asterisk beside the input field within Bootstrap

Trying to insert a red * at the end of my input field using bootstrap, but all my attempts so far have been unsuccessful. Is there a way to align the Currently experiencing this issue: https://i.stack.imgur.com/61pzb.png Code snippet: .required-after ...

Creating a minigame using JQuery (Javascript)

I am currently developing a collection of mini-games for my big project. The approach I've taken in creating this mini-game is similar to one I used previously. However, unlike my previous version which only had one PuzzleContainer, this new iteration ...

What is the best way to address a row of hyperlink text located at the top of a webpage?

I have encountered an issue where three rows of text links near the top of a page shift up to the very top when a link is pressed, causing them to obscure a line of text that was already at the top. How can I keep the position of these three rows anchored? ...

Ways to adjust the dimensions of a textarea based on character count

When attempting to utilize the cols and rows attributes of the <textarea> element in order to set the width and height in characters, I have encountered issues even without implementing CSS. Take a look at this example: link I have configured a 5x5 ...

The image appears on the browser, however, it does not render within the <img> tag in

I am facing an issue with displaying images from a DigitalOcean space in my reactJS application. When I try to display the image using an img tag like this: const search = 'https://wantedoffice.dev.bucket.ams3.digitaloceanspaces.com/smartphone.png&a ...

Reports of missing packages in the React Starter Kit have caused confusion among users

While I may be new to React/JS, I have a wide range of experience in different technologies, including some work with Angular/JS. Therefore, my encounter with the Node/JS ecosystem is not completely fresh. The journey began when I encountered a missing pe ...

Any solutions for dealing with longer labels in Bootstrap form-floating?

Is there a way to use Bootstrap's form-floating feature with longer labels so that the text box automatically expands to accommodate the text but doesn't cut off on white-space wrap when too long? I'd like to avoid using position-relative to ...

Changing the name of a React Native sample application

I am currently working on a project based on this App example: https://github.com/aksonov/react-native-router-flux/tree/master/Example When I tried to change the following lines: index.ios.js import App from './App'; AppRegistry.regist ...

Develop an asynchronous thunk with TypeScript in Redux Toolkit, utilizing the features of rejectWithValue and Payload types for handling errors

Struggling to integrate an authentication slice into Redux Toolkit using TypeScript, facing errors related to rejectWithValue and action payload types. Utilizing Axios and following the documentation, but TypeScript is still flagging issues in my code. im ...

Simultaneously logging into an Asp.Net Core 2.0 MVC application using cookies and accessing a REST API using JWT authentication

I'm currently utilizing the VS 2017 Asp.Net Core 2.0 web application template along with the React.js template option. This setup provides me with a basic MVC + React structure including: 1. a single MVC page serving as the host for the React applica ...

Utilizing Material-UI to Automatically Capitalize Words in React

Looking to transform the text inside a <TextField> element into capital letters. Current text: LeaGUE oF lEGENdS Desired format: League Of Legends Attempting to use text-transform: 'capitalize', however, it's not behaving as antic ...

Ensure the hour field is accurate using yup validators

I am using material-ui's TextField component with a field labeled as "hour." I need to implement Yup validation to enforce a specific format for the input value, which should follow this pattern: 02:30 Can someone guide me on how to achieve this usin ...

Is it possible to use Material-UI Link along with react-router-dom Link?

Incorporating these two elements: import Link from '@material-ui/core/Link'; import { Link } from 'react-router-dom'; Is there a method to combine the Material-UI style with the features of react-router-dom? ...

Navigate to a different tab using react router by adding history.push with a new link

After executing some logic, I want to open a link in a new tab. This is the button I have: <Button onClick={handleSubmit} > Preview </Button> The handleSubmit() function looks like this: const history = useHistory(); const handleSubmit = ...