Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize Color of Scrollbar #11

Open
gbroques opened this issue Sep 11, 2020 · 5 comments
Open

Customize Color of Scrollbar #11

gbroques opened this issue Sep 11, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@gbroques
Copy link

How would we customize the color of the scrollbar from the default of rgba(0, 0, 0, .1)?

I'd like to use this in an application with a dark background color, and rgba(0, 0, 0, .1) doesn't show up well on dark backgrounds.

@ivnflpz
Copy link

ivnflpz commented Feb 6, 2021

@gbroques I was able to customize the color by looking at the structure of the html and realizing that I can target the last child div of the CustomScroller. It's somewhat hacky but it works given we can't directly add classes to the track element.

If you're using makeStyles from material-ui, you can do something like this

import * as React from "react";
import { makeStyles } from "@material-ui/core";
import CustomScroller from "react-custom-scroller";

const useStyles = makeStyles({
  scroller: {
    "&> div:last-child": {
      background: "rgba(34, 157, 158, 0.4)",
    },
  },
});

const CustomColorScoller = ({ children }) => {
  const classes = useStyles();
  return (
    <CustomScroller className={classes.scroller}>{children}</CustomScroller>
  );
};

export default CustomColorScoller;

@gbroques
Copy link
Author

gbroques commented Feb 9, 2021

@ivnflpz Thank you for the workaround! I will close this issue. 😄

@gbroques gbroques closed this as completed Feb 9, 2021
@buzinas buzinas reopened this Feb 9, 2021
@buzinas
Copy link
Collaborator

buzinas commented Feb 9, 2021

I'll keep it open because we plan to add an official way of doing this via props.

@buzinas buzinas added the enhancement New feature or request label Feb 9, 2021
@gbroques
Copy link
Author

gbroques commented Feb 9, 2021

I'll keep it open because we plan to add an official way of doing this via props.

This would be great. :)

@ApplePieGiraffe
Copy link

Yes, this would be awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants