easeul

Radix UIKeyframes

Scroll area

The subtlest comparison here, so watch the bar leave rather than arrive. Scroll, stop, and wait: on the left the bar is removed on a single frame, on the right it fades. The hide delay is stretched well past the Radix default to make that visible at all. This is also a third state pair that means open and closed without saying so.

Every value the manifest allows on this host, single presets and the pairs that compose. The first is what this component ships with. Both stages are the same component, so anything that changes between them is the attribute.

withoutno attribute

Scroll this box, then stop. Watch the bar on the right as it leaves rather than as it arrives.

Without the attribute it is removed on the same frame the hide delay elapses. With it, the bar fades out.

The scrollbar reports visible and hidden rather than open and closed, which is a third way of spelling the same state pair.

Keep going so there is room to scroll.

One last line.

with easefuldata-motion="fade"

Scroll this box, then stop. Watch the bar on the right as it leaves rather than as it arrives.

Without the attribute it is removed on the same frame the hide delay elapses. With it, the bar fades out.

The scrollbar reports visible and hidden rather than open and closed, which is a third way of spelling the same state pair.

Keep going so there is room to scroll.

One last line.

host writes

data-state="visible" | "hidden"

easeful matches

[data-motion~="fade"][data-state="hidden"]

what runs

animation: motion-exit 150ms

you write

<ScrollArea.Scrollbar data-motion="fade" />

Where the attribute goes

The parts this demo composes, and the value each one carries. Everything inside an animated part is that part's content, so the tree stops there.

  1. ScrollArea.Root
  2. ScrollArea.Viewport
  3. ScrollArea.Scrollbardata-motion="fade"

Source

"use client"

import { ScrollArea } from "radix-ui"
import type { DemoProps } from "@/components/demos/props"

/* scrollHideDelay is stretched well past the Radix default. The scrollbar fade
 * is the subtlest comparison on the site, and at the default delay the bar is
 * gone before you can look at it. */
export function RadixScrollArea({ motion }: DemoProps) {
  return (
    <ScrollArea.Root className="scroller" type="scroll" scrollHideDelay={900}>
      <ScrollArea.Viewport className="scroller__viewport">
        <p>
          Scroll this box, then stop. Watch the bar on the right as it leaves rather than as it
          arrives.
        </p>
        <p>
          Without the attribute it is removed on the same frame the hide delay elapses. With it,
          the bar fades out.
        </p>
        <p>
          The scrollbar reports visible and hidden rather than open and closed, which is a third
          way of spelling the same state pair.
        </p>
        <p>Keep going so there is room to scroll.</p>
        <p>One last line.</p>
      </ScrollArea.Viewport>
      <ScrollArea.Scrollbar className="scroller__bar" orientation="vertical" data-motion={motion}>
        <ScrollArea.Thumb className="scroller__thumb" />
      </ScrollArea.Scrollbar>
    </ScrollArea.Root>
  )
}
The whole file, read from disk at build time. Both copies above render from it, and the motion prop is the only difference between them.