Components Editor chrome

Scrollbar

A persistent scrollbar for a virtual document viewport, with a proportional thumb, dragging, track clicks and keyboard navigation.

import { Scrollbar } from '@kition/tessera-ui'

When to use

  • A canvas pans through a bounded document instead of scrolling DOM content.

When not to

  • An ordinary DOM list: use native overflow scrolling.

Examples

Page sections
Page section 1
Page section 2
Page section 3
Page section 4
Page section 5
Page section 6
Page section 7
Page section 8
Page section 9
Page section 10
Page section 11
Page section 12
Page section 13
Page section 14
Page section 15
Page section 16
Page section 17
Page section 18
Page section 19
Page section 20
scrollbar.tsx
import { useState } from 'react'
import { Scrollbar } from '@kition/tessera-ui'

export default function Demo() {
  const [offset, setOffset] = useState(0)
  return (
    <div style={{ display: 'flex', height: 200, width: 300, border: '1px solid var(--kit-border)' }}>
      <div style={{ flex: 1, overflow: 'hidden' }}>
        <div style={{ transform: `translateY(${-offset}px)` }}>
          {Array.from({ length: 20 }, (_, index) => <div key={index} style={{ height: 40, paddingLeft: 12 }}>Page section {index + 1}</div>)}
        </div>
      </div>
      <Scrollbar label="Page sections" value={offset} max={600} page={200} onChange={setOffset} />
    </div>
  )
}

Props

Scrollbar

A persistent scrollbar for virtual viewports, with proportional thumb, pointer capture and keyboard navigation.

PropTypeDefaultDescription
labelrequiredstring—Accessible name supplied by the editor's locale.
orientation'vertical' | 'horizontal''vertical'
valuerequirednumber—Distance from the start of the content, in the caller's coordinates.
maxrequirednumber—Maximum scroll distance (content length minus visible length).
pagerequirednumber—Visible content length, in the same coordinates as value.
onChangerequired(value: number) => void—
controlsstring—

Used in

2 of Kition's 16 kits use this component.

  • Doc
  • Pdf