Skip to content

Instantly share code, notes, and snippets.

@yano3nora
Last active March 8, 2025 06:08
Show Gist options
  • Save yano3nora/c49d1b058633784097b78b06b24ba81d to your computer and use it in GitHub Desktop.
Save yano3nora/c49d1b058633784097b78b06b24ba81d to your computer and use it in GitHub Desktop.
overlay-scrollbars-react

Overview

https://kingsora.github.io/OverlayScrollbars/
https://github.com/KingSora/OverlayScrollbars

Usage

npm i overlayscrollbars
import 'overlayscrollbars/overlayscrollbars.css'
import { OverlayScrollbarsComponent } from 'overlayscrollbars-react'

return <OverlayScrollbarsComponent
  defer
  options={{ scrollbars: { autoHide: 'scroll' } }}
  style={{
    // 余白調整はここで
    paddingLeft: 60,
    paddingRight: 60,
    paddingTop: 20,
    paddingBottom: 20,
    width: '100vw',
    height: 'calc(100vh - 65px)', // fixed なヘッダとかあれば calc してやる
  }}
>
  {/* fit-content はさむと余白調整がうまくいく */}
  <div style={{ width: 'fit-content', height: 'fit-content'}}>
    <div style={{ width: 2560, height: 1440, background: 'red' }}>
      huge content
    </div>
  </div>
</OverlayScrollbarsComponent>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment