Scrollable content
Keep the title and actions visible while long content scrolls. The body is a named, focusable region so keyboard users can scroll it.
"use client"
import { Button } from "@/components/ui/button"
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"
const terms = [
"Workspace owners can invite members, change roles and remove access at any time.",
"Content you upload stays yours. We process it only to provide the service you configured.",
"Usage above your plan's limits is billed at the end of each billing period.",
"You can export your data in a standard format before closing an account.",
"We announce changes to these terms at least 30 days before they take effect.",
"Either party can end the agreement with written notice, as described in section 9.",
]
export function DialogScrollableContent() {
return (
<div className="flex flex-wrap items-center gap-3">
<Dialog>
<DialogTrigger asChild>
<Button intent="neutral" emphasis="stroke">
Read terms
</Button>
</DialogTrigger>
<DialogContent className="max-h-[85dvh] grid-rows-[auto_minmax(0,1fr)_auto]">
<DialogHeader>
<DialogTitle>Terms of service</DialogTitle>
<DialogDescription>
Last updated in March. The summary below scrolls; the actions stay
visible.
</DialogDescription>
</DialogHeader>
<div
tabIndex={0}
role="region"
aria-label="Terms summary"
className="flex flex-col gap-3 overflow-y-auto rounded-8 text-paragraph-sm text-sub-600 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-base"
>
{[...terms, ...terms].map((term, index) => (
<p key={index}>
{index + 1}. {term}
</p>
))}
</div>
<DialogFooter>
<DialogClose asChild>
<Button intent="neutral" emphasis="stroke">
Not now
</Button>
</DialogClose>
<DialogClose asChild>
<Button>Accept terms</Button>
</DialogClose>
</DialogFooter>
</DialogContent>
</Dialog>
</div>
)
}