:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
import { Meta, StoryObj } from '@storybook/react'
import { useRef } from 'react'
import { LemonButton } from '@posthog/lemon-ui'
import { ScrollableShadows, ScrollableShadowsProps } from './ScrollableShadows'
const meta: Meta<ScrollableShadowsProps> = {
title: 'Lemon UI/Scrollable Shadows',
component: ScrollableShadows,
tags: ['autodocs'],
}
export default meta
type Story = StoryObj<ScrollableShadowsProps>
export const Horizontal: Story = {
render: () => {
const scrollRef = useRef<HTMLDivElement | null>(null)
return (
<>
<ScrollableShadows
className="border rounded w-200 resize"
innerClassName="p-4"
direction="horizontal"
scrollRef={scrollRef}
>
<div className="flex gap-2 items-center">
{Array.from({ length: 100 }).map((_, index) => (
<div key={index} className="w-24 h-24 shrink-0 bg-accent rounded" />
))}
</div>
</ScrollableShadows>
<div className="flex gap-2 mt-4">
<LemonButton
onClick={() => {
scrollRef.current?.scrollBy({ left: -100, behavior: 'smooth' })
}}
>
Scroll Left
</LemonButton>
<LemonButton
onClick={() => {
scrollRef.current?.scrollBy({ left: 100, behavior: 'smooth' })
}}
>
Scroll Right
</LemonButton>
</div>
</>
)
},
}
export const Vertical: Story = {
render: () => {
const scrollRef = useRef<HTMLDivElement | null>(null)
return (
<>
<ScrollableShadows
className="border rounded w-60 h-100 resize"
innerClassName="p-4"
direction="vertical"
scrollRef={scrollRef}
>
<div className="flex flex-col gap-2 items-center">
{Array.from({ length: 100 }).map((_, index) => (
<div key={index} className="w-24 h-24 shrink-0 bg-accent rounded" />
))}
</div>
</ScrollableShadows>
<div className="flex gap-2 mt-4">
<LemonButton
onClick={() => {
scrollRef.current?.scrollBy({ top: -100, behavior: 'smooth' })
}}
>
Scroll Up
</LemonButton>
<LemonButton
onClick={() => {
scrollRef.current?.scrollBy({ top: 100, behavior: 'smooth' })
}}
>
Scroll Down
</LemonButton>
</div>
</>
)
},
}