Open this example in the interactive library
Live preview
Source code
// components/ScrollableContentRail.tsx
import { Children } from "react";
import type { ReactNode } from "react";
export default function ScrollableContentRail({
children = "Your content",
}: { children?: ReactNode } = {}) {
return (
<section
aria-label="Featured items"
tabIndex={0}
style={{
display: "flex",
overflowX: "auto",
scrollSnapType: "x mandatory",
gap: "1rem",
}}
>
{Children.toArray(children).map((child, i) => (
<div key={i} style={{ flex: "0 0 75%", scrollSnapAlign: "start" }}>
{child}
</div>
))}
</section>
);
}
