Scroll shadow
A scrollable area that shows soft shadows at the edges while there is more content, in pure CSS.
Installation
bash
npx bootcn add scroll-shadowbash
pnpm dlx bootcn add scroll-shadowbash
yarn dlx bootcn add scroll-shadowbash
bunx --bun bootcn add scroll-shadowThe CLI also installs the design tokens and these components: none. It prints the <link> and <script> tags to add to your layout.
Usage
Give the area a height or max-height. The shadows come from background gradients (no JavaScript): the content's background covers them at the start and end, so a shadow appears only when there is more to scroll. On a colored background, set --bootcn-scroll-shadow-cover to that color.
Accessibility
- A focusable
<section>with a name, so keyboard users can scroll it. - The shadows are a visual hint only; nothing depends on them.
Dependencies
- Bootstrap 5.3+ CSS.
themes/tokens/tokens.css.
Source
The exact files the CLI installs (scroll-shadow@1.0.0). View on GitHub · Report an issue
html
<section
class="bootcn-scroll-shadow"
tabindex="0"
aria-label="Release notes"
style="max-height: 12rem; max-width: 24rem"
>
<p>Release 0.11.0: six blocks and the analytics dashboard template.</p>
<p>Release 0.10.0: accessible SVG charts and seven chart cards.</p>
<p>Release 0.9.0: calendar, date picker, data table and sidebar.</p>
<p>Release 0.8.0: navigation menu, carousel, input OTP and resizable panels.</p>
<p>Release 0.7.0: combobox, command palette, context menu and menubar.</p>
<p>Release 0.6.0: twenty-three new components.</p>
<p>Release 0.5.0: marketing blocks.</p>
<p>Release 0.4.0: the Tailwind-like look on Bootstrap.</p>
<p>Release 0.3.0: blocks and the admin dashboard template.</p>
<p>Release 0.2.0: the first public registry.</p>
</section>css
.bootcn-scroll-shadow {
--bootcn-scroll-shadow-color: rgba(0, 0, 0, 0.14);
--bootcn-scroll-shadow-cover: var(--bootcn-background);
overflow: auto;
padding: 0 1rem;
border: var(--bootcn-border-width) solid var(--bootcn-border-color);
border-radius: var(--bootcn-radius-lg);
/* Covers scroll with the content (local); shadows stay at the edges
(scroll). A shadow shows only where content hides behind an edge. */
background:
linear-gradient(var(--bootcn-scroll-shadow-cover) 30%, transparent) center top,
linear-gradient(transparent, var(--bootcn-scroll-shadow-cover) 70%) center bottom,
radial-gradient(farthest-side at 50% 0, var(--bootcn-scroll-shadow-color), transparent) center
top,
radial-gradient(farthest-side at 50% 100%, var(--bootcn-scroll-shadow-color), transparent)
center bottom;
background-repeat: no-repeat;
background-size:
100% 2.5rem,
100% 2.5rem,
100% 0.875rem,
100% 0.875rem;
background-attachment: local, local, scroll, scroll;
font-size: 0.875rem;
}
[data-bs-theme='dark'] .bootcn-scroll-shadow {
--bootcn-scroll-shadow-color: rgba(255, 255, 255, 0.16);
}
.bootcn-scroll-shadow:focus-visible {
outline: 0;
box-shadow: var(--bootcn-focus-ring);
}
.bootcn-scroll-shadow > p {
margin: 0;
padding: 0.625rem 0;
}
.bootcn-scroll-shadow > p + p {
border-top: var(--bootcn-border-width) solid var(--bootcn-border-color);
}
