Components

Scroll area

A box that scrolls instead of the page, its bars thin or drawn over it.

Previews are drawn in the theme you made.

Edit it
orientation
gutter
scheme
direction

The browser’s bars #

  • Release 0.24.0
  • Release 0.23.0
  • Release 0.22.0
  • Release 0.21.0
  • Release 0.20.0
  • Release 0.19.0
  • Release 0.18.0
  • Release 0.17.0
  • Release 0.16.0
  • Release 0.15.0
  • Release 0.14.0
  • Release 0.13.0
  • Release 0.12.0
  • Release 0.11.0
  • Release 0.10.0
  • Release 0.9.0
  • Release 0.8.0
  • Release 0.7.0
  • Release 0.6.0
  • Release 0.5.0
  • Release 0.4.0
  • Release 0.3.0
  • Release 0.2.0
  • Release 0.1.0
import { Recipes, ScrollArea, ScrollAreaSlots } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'

// The height that makes the box scroll is the application's: the recipe
// extended by one, here.
export const Tall = Recipes.ScrollArea.extend({ base: { viewport: { maxBlockSize: '12rem' } } })

// The box scrolls instead of the page, in the browser's own thin bars.
export default example({
  title: 'The browser’s bars',
  slots: ScrollAreaSlots,
  recipe: Tall,
  view: ({ style, h }) =>
    ScrollArea.view(
      {
        label: 'Releases',
        content: h.ul(
          [h.Style({ margin: '0', paddingInline: '1rem' })],
          Array.from({ length: 24 }, (_, index) => h.li([], [`Release 0.${24 - index}.0`])),
        ),
        style,
      },
      h,
    ),
})

In your application: recipe goes to forSlots, and the body of view is the call. example is this site’s harness.

Overlay bars #

  • Release 0.24.0
  • Release 0.23.0
  • Release 0.22.0
  • Release 0.21.0
  • Release 0.20.0
  • Release 0.19.0
  • Release 0.18.0
  • Release 0.17.0
  • Release 0.16.0
  • Release 0.15.0
  • Release 0.14.0
  • Release 0.13.0
  • Release 0.12.0
  • Release 0.11.0
  • Release 0.10.0
  • Release 0.9.0
  • Release 0.8.0
  • Release 0.7.0
  • Release 0.6.0
  • Release 0.5.0
  • Release 0.4.0
  • Release 0.3.0
  • Release 0.2.0
  • Release 0.1.0
import { ScrollArea, ScrollAreaSlots } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'
import { Tall } from './native.js'

// Bars drawn over the content in place of the browser's, on a pointer that
// can hover; a coarse pointer keeps the browser's. Off unless passed, so a
// page that never names `overlayBars` never ships the bar Mount.
export default example({
  title: 'Overlay bars',
  slots: ScrollAreaSlots,
  recipe: Tall,
  view: ({ style, h }) =>
    ScrollArea.view(
      {
        label: 'Releases',
        content: h.ul(
          [h.Style({ margin: '0', paddingInline: '1rem' })],
          Array.from({ length: 24 }, (_, index) => h.li([], [`Release 0.${24 - index}.0`])),
        ),
        mixins: ScrollArea.overlayBars,
        style,
      },
      h,
    ),
})

In your application: recipe goes to forSlots, and the body of view is the call. example is this site’s harness.

Horizontal #

tag-1tag-2tag-3tag-4tag-5tag-6tag-7tag-8tag-9tag-10tag-11tag-12tag-13tag-14tag-15tag-16tag-17tag-18tag-19tag-20tag-21tag-22tag-23tag-24
import { Recipes, ScrollArea, ScrollAreaSlots } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'

// One axis may scroll: the orientation says which. The edge with more past it
// fades, and a line marks it.
export default example({
  title: 'Horizontal',
  slots: ScrollAreaSlots,
  recipe: Recipes.ScrollArea,
  pins: { orientation: 'horizontal' },
  view: ({ style, h }) =>
    ScrollArea.view(
      {
        label: 'Tags',
        content: h.div(
          [h.Style({ display: 'flex', gap: '0.75rem', whiteSpace: 'nowrap', padding: '0.5rem' })],
          Array.from({ length: 24 }, (_, index) => h.span([], [`tag-${index + 1}`])),
        ),
        style,
      },
      h,
    ),
})

In your application: recipe goes to forSlots, and the body of view is the call. example is this site’s harness.

A stable gutter #

  • Change 1
  • Change 2
  • Change 3
  • Change 4
  • Change 5
  • Change 6
  • Change 7
  • Change 8
  • Change 9
  • Change 10
  • Change 11
  • Change 12
  • Change 13
  • Change 14
  • Change 15
  • Change 16
import { ScrollArea, ScrollAreaSlots } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'
import { Tall } from './native.js'

// `gutter: 'stable'` keeps the room a bar takes, so the content does not
// shift sideways when the box starts to scroll.
export default example({
  title: 'A stable gutter',
  slots: ScrollAreaSlots,
  recipe: Tall,
  pins: { gutter: 'stable' },
  view: ({ style, h }) =>
    ScrollArea.view(
      {
        label: 'Changes',
        content: h.ul(
          [h.Style({ margin: '0', paddingInline: '1rem' })],
          Array.from({ length: 16 }, (_, index) => h.li([], [`Change ${index + 1}`])),
        ),
        style,
      },
      h,
    ),
})

In your application: recipe goes to forSlots, and the body of view is the call. example is this site’s harness.

Configure once #

  • Note 1
  • Note 2
  • Note 3
  • Note 4
  • Note 5
  • Note 6
  • Note 7
  • Note 8
  • Note 9
  • Note 10
  • Note 11
  • Note 12
  • Note 13
  • Note 14
  • Note 15
  • Note 16
  • Note 17
  • Note 18
  • Note 19
  • Note 20
import { Recipes, ScrollArea, ScrollAreaSlots } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'
import { forSlots } from '../../snippets/theme.js'
import { Tall } from './native.js'

const Boxed = forSlots(ScrollAreaSlots)(Tall({ gutter: 'stable' }))

// What every scroll area of an application starts from: its height and look,
// and the bars it draws, said once. `overlayBars` is a value in `base`, so only
// an application that names it ships it.
const AppScroll = ScrollArea.configure({
  base: { style: Boxed, mixins: ScrollArea.overlayBars },
})

export default example({
  title: 'Configure once',
  slots: ScrollAreaSlots,
  recipe: Recipes.ScrollArea,
  view: ({ h }) =>
    AppScroll.view(
      {
        label: 'Notes',
        content: h.ul(
          [h.Style({ margin: '0', paddingInline: '1rem' })],
          Array.from({ length: 20 }, (_, index) => h.li([], [`Note ${index + 1}`])),
        ),
      },
      h,
    ),
})

In your application: recipe goes to forSlots, and the body of view is the call. example is this site’s harness.

Usage

Each example above is a module of its own, shown whole and run as shown, over the theme module Create a theme writes. The page hands it the style picked above.

The recipe ↗This code ↗