apps/docs/content/docs/react/components/(utilities)/scroll-shadow.mdx
import { ScrollShadow } from "@heroui/react";
import {ScrollShadow, Card} from "@heroui/react";
function CustomScrollShadow() {
return (
<Card className="w-full p-0 sm:max-w-md">
<ScrollShadow className="max-h-[300px] p-6 bg-gradient-to-b from-purple-50 to-pink-50">
<div className="space-y-4">
{Array.from({length: 10}).map((_, idx) => (
<p key={idx}>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam pulvinar risus non
risus hendrerit venenatis.
</p>
))}
</div>
</ScrollShadow>
</Card>
);
}
To customize the ScrollShadow component classes, you can use the @layer components directive.
@layer components {
.scroll-shadow {
@apply rounded-xl border border-default-200;
}
.scroll-shadow--vertical {
@apply pr-2; /* Add padding for custom scrollbar styling */
}
.scroll-shadow--horizontal {
@apply pb-2;
}
}
HeroUI follows the BEM methodology to ensure component variants and states are reusable and easy to customize.
The ScrollShadow component uses these CSS classes (View source styles):
.scroll-shadow - Root container element.scroll-shadow--vertical - Vertical scrolling (default).scroll-shadow--horizontal - Horizontal scrolling.scroll-shadow--hide-scrollbar - Hides native scrollbarThe component uses data attributes to control shadow visibility:
[data-top-scroll], [data-bottom-scroll], [data-left-scroll], [data-right-scroll] - Applied when content can be scrolled in that direction[data-top-bottom-scroll], [data-left-right-scroll] - Applied when content can be scrolled in both directions[data-orientation="vertical"] or [data-orientation="horizontal"] - Indicates scroll direction[data-scroll-shadow-size] - Contains the shadow gradient size value| Prop | Type | Default | Description |
|---|---|---|---|
orientation | "vertical" | "horizontal" | "vertical" | The scroll direction |
variant | "fade" | "fade" | The visual shadow effect style |
size | number | 40 | The shadow gradient size in pixels |
offset | number | 0 | The scroll offset before showing shadows (in pixels) |
hideScrollBar | boolean | false | Whether to hide the native scrollbar |
isEnabled | boolean | true | Whether scroll shadow detection is enabled |
visibility | "auto" | "both" | "top" | "bottom" | "left" | "right" | "none" | "auto" | Controlled shadow visibility state |
onVisibilityChange | (visibility: ScrollShadowVisibility) => void | - | Callback invoked when shadow visibility changes |
className | string | - | Additional CSS classes to apply to the root element |
children | ReactNode | - | The scrollable content |