fumadocs-ui
Version:
The Radix UI version of Fumadocs UI
35 lines (34 loc) • 1.26 kB
JavaScript
import { cn } from "../../utils/cn.js";
import { jsx, jsxs } from "react/jsx-runtime";
import "react";
import * as Primitive from "@radix-ui/react-scroll-area";
//#region src/components/ui/scroll-area.tsx
function ScrollArea({ className, children, ...props }) {
return /* @__PURE__ */ jsxs(Primitive.Root, {
type: "scroll",
className: cn("overflow-hidden", className),
...props,
children: [
children,
/* @__PURE__ */ jsx(Primitive.Corner, {}),
/* @__PURE__ */ jsx(ScrollBar, { orientation: "vertical" })
]
});
}
function ScrollViewport({ className, children, ...props }) {
return /* @__PURE__ */ jsx(Primitive.Viewport, {
className: cn("size-full rounded-[inherit]", className),
...props,
children
});
}
function ScrollBar({ className, orientation = "vertical", ...props }) {
return /* @__PURE__ */ jsx(Primitive.Scrollbar, {
orientation,
className: cn("flex select-none data-[state=hidden]:animate-fd-fade-out", orientation === "vertical" && "h-full w-1.5", orientation === "horizontal" && "h-1.5 flex-col", className),
...props,
children: /* @__PURE__ */ jsx(Primitive.ScrollAreaThumb, { className: "relative flex-1 rounded-full bg-fd-border" })
});
}
//#endregion
export { ScrollArea, ScrollBar, ScrollViewport };