BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/lina/lina-base

Base UI Adaptive Scroll Area

lina/lina-base
FreeComponent

A responsive scroll area that feel native on touch devices, offereing custom styling and enchanced interactions where it matter most.

Install it

npx shadcn@latest add https://lina.sameer.sh/r/lina-base.json

Source

registry/base-ui/scroll-area.tsxlina.sameer.sh/r/lina-base.json · first 6 KB
1"use client";
2
3import * as React from "react";
4
5import { ScrollArea as ScrollAreaPrimitive } from "@base-ui-components/react/scroll-area";
6
7import { cn } from "@/lib/utils";
8
9import { useTouchPrimary } from "@/hooks/use-has-primary-touch";
10
11type Mask = {
12 top: boolean;
13 bottom: boolean;
14 left: boolean;
15 right: boolean;
16};
17
18export type ScrollAreaContextProps = {
19 isTouch: boolean;
20 type: "auto" | "always" | "scroll" | "hover";
21};
22
23const ScrollAreaContext = React.createContext<ScrollAreaContextProps>({
24 isTouch: false,
25 type: "hover",
26});
27
28const ScrollArea = React.forwardRef<
29 React.ComponentRef<typeof ScrollAreaPrimitive.Root>,
30 React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root> & {
31 type?: "auto" | "always" | "scroll" | "hover";
32 viewportClassName?: string;
33 /**
34 * `maskHeight` is the height of the mask in pixels.
35 * pass `0` to disable the mask
36 * @default 30
37 */
38 maskHeight?: number;
39 maskClassName?: string;
40 }
41>(({ className, children, type = "hover", maskHeight = 30, maskClassName, viewportClassName, ...props }, ref) => {
42 const [showMask, setShowMask] = React.useState<Mask>({
43 top: false,
44 bottom: false,
45 left: false,
46 right: false,
47 });
48
49 const viewportRef = React.useRef<HTMLDivElement>(null);
50 const isTouch = useTouchPrimary();
51
52 const checkScrollability = React.useCallback(() => {
53 const element = viewportRef.current;
54 if (!element) return;
55
56 const { scrollTop, scrollLeft, scrollWidth, clientWidth, scrollHeight, clientHeight } = element;
57 setShowMask((prev) => ({
58 ...prev,
59 top: scrollTop > 0,
60 bottom: scrollTop + clientHeight < scrollHeight - 1,
61 left: scrollLeft > 0,
62 right: scrollLeft + clientWidth < scrollWidth - 1,
63 }));
64 }, []);
65
66 React.useEffect(() => {
67 if (typeof window === "undefined") return;
68
69 const element = viewportRef.current;
70 if (!element) return;
71
72 const controller = new AbortController();
73 const { signal } = controller;
74
75 const resizeObserver = new ResizeObserver(checkScrollability);
76 resizeObserver.observe(element);
77
78 element.addEventListener("scroll", checkScrollability, { signal });
79 window.addEventListener("resize", checkScrollability, { signal });
80
81 // Run an initial check whenever dependencies change (including pointer mode)
82 checkScrollability();
83
84 return () => {
85 controller.abort();
86// … truncated

What it pulls in

npm packages

  • @base-ui-components/react

Files it writes

  • registry/base-ui/scroll-area.tsx
  • hooks/use-has-primary-touch.tsx

Facts

Registry
lina
Type
registry:ui
Access
Free
Files written
2
Licence
MIT
First indexed
2026-08-01
Last confirmed
yesterday

Go to the source

lina.sameer.sh SameerJS6/lina on GitHub Raw registry item This item as JSON

More from lina

All 10 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Command based on Lina's Base UI variantcommand-baselinaComponentsFree2 deps
Command based on Lina's Radix UI variantcommand-radixlinaComponentsFree2 deps
Horizontal Scroll Area Base Demohorizontal-scroll-demo-baselinaComponentsFreeno deps
Horizontal Scroll Area Radix Demohorizontal-scroll-demo-radixlinaComponentsFreeno deps
Radix Adaptive Scroll Arealina-radixlinaComponentsFree1 dep · 2 files
Timezone Select Base UI Demotimezone-select-demo-baselinaComponentsFree1 dep
Timezone Select Radix Demotimezone-select-demo-radixlinaComponentsFree1 dep
Vertical Scroll Area Base Demovertical-scroll-demo-baselinaComponentsFreeno deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex