shadcn.io is not affiliated with official shadcn/ui
Dialog examples · Standard
Terms and Conditions Dialog for React
A terms dialog whose I Agree button stays disabled until the reader scrolls to the end of the text.
Accepting terms nobody read helps no one. This React dialog keeps I Agree disabled until the reader has scrolled to the end of the terms. It's shadcn.io's Dialog on Base UI, with the terms in a scrolling area whose scroll position is checked as people read.
Preview
Installation
FAQ
How is the end of the text detected?
The terms sit in a div with h-75 overflow-y-auto, and its scroll handler checks whether scrollHeight - scrollTop - clientHeight is under 10 pixels. Once it is, I Agree is enabled for good.
Is forcing a scroll good UX?
For legal agreements you must prove were shown, it's defensible. For everything else, a checkbox confirmation is friendlier.
Should the button say why it's disabled?
Yes: add a short line under the terms such as Scroll to the end to accept, and remove it once the button is enabled.
How is I Agree disabled?
The button takes disabled until the reader reaches the end. It's a DialogClose, so it closes the dialog once pressed.
Related
- Scrollable DialogA privacy policy dialog whose long text
- Scrollable with Sticky Header DialogA changelog dialog whose header stays in
- Simple CheckboxA checkbox with a label for a single
- Button with Text (Standard)The one filled action
- Basic ScrollArea Scroll AreaA basic vertical scroll area for long
- Simple Confirmation Dialog Alert DialogA simple confirmation dialog with Cancel