React-custom-scrollbars: vertical track

Created on 6 Feb 2018  路  2Comments  路  Source: malte-wessel/react-custom-scrollbars

Most helpful comment

As a workaround, you can import defaultRenderElements and customize them, like it's described here

Example with adding custom classes (should works):

import {
  renderTrackHorizontalDefault,
  renderTrackVerticalDefault,
  renderThumbHorizontalDefault,
  renderThumbVerticalDefault,
} from 'react-custom-scrollbars/lib/Scrollbars/defaultRenderElements';

const Scrollbar = scrollProps => {
  return (
    <Scrollbars
      renderTrackHorizontal={props => renderTrackHorizontalDefault({ ...props, className: 'track-horizontal' })}
      renderTrackVertical={props => renderTrackVerticalDefault({ ...props, className: 'track-vertical' })}
      renderThumbHorizontal={props => renderThumbHorizontalDefault({ ...props, className: 'thumb-horizontal' })}
      renderThumbVertical={props => renderThumbVerticalDefault({ ...props, className: 'thumb-vertical' })}
      {...scrollProps}
    />
  );
};

All 2 comments

As a workaround, you can import defaultRenderElements and customize them, like it's described here

Example with adding custom classes (should works):

import {
  renderTrackHorizontalDefault,
  renderTrackVerticalDefault,
  renderThumbHorizontalDefault,
  renderThumbVerticalDefault,
} from 'react-custom-scrollbars/lib/Scrollbars/defaultRenderElements';

const Scrollbar = scrollProps => {
  return (
    <Scrollbars
      renderTrackHorizontal={props => renderTrackHorizontalDefault({ ...props, className: 'track-horizontal' })}
      renderTrackVertical={props => renderTrackVerticalDefault({ ...props, className: 'track-vertical' })}
      renderThumbHorizontal={props => renderThumbHorizontalDefault({ ...props, className: 'thumb-horizontal' })}
      renderThumbVertical={props => renderThumbVerticalDefault({ ...props, className: 'thumb-vertical' })}
      {...scrollProps}
    />
  );
};

Thanks so much! I just spent about half an hour trying to figure out why copying the example customization code _was not_ working.

Was this page helpful?
0 / 5 - 0 ratings