scroll Component
📐 Align UI Design Reference
File: Align UI ✦ Design System [1.1]
Page: Scroll
Scrollbar Sizes: 12px (x-small), 16px (small), 20px (medium)
Styles: Default (white bg, light scrollbar) and Lighter (gray bg, darker scrollbar)
Features: Webkit and Firefox scrollbar styling, smooth scrolling, touch support
Overview
Customizable scrollbar component that styles native browser scrollbars for vertical and horizontal scrolling containers. Supports multiple sizes, style variants, and responsive behavior with full accessibility support.
Size Variants
Tiny (10px scrollbar)
Tiny Scrollbar
Perfect for compact interfaces and minimal designs.
- • Compact 10px scrollbar width
- • Ideal for sidebars
- • Minimal visual weight
- • Mobile-friendly
- • Best for small containers
- • Less obtrusive design
- • Saves screen space
- • Modern aesthetic
Small (12px scrollbar)
Small Scrollbar
Great balance between visibility and subtlety.
- • Standard 12px scrollbar width
- • Good for most use cases
- • Balanced visibility
- • Works well on tablets
- • Commonly used size
- • Easy to interact with
- • Not too prominent
- • Versatile option
Default (16px scrollbar)
Default Scrollbar
Standard size for most applications. No class needed - this is the default!
Key Features
- • Comfortable 16px scrollbar width
- • Optimal for desktop interfaces
- • Easy to grab and drag
- • Clear visual indicator
- • Accessible for all users
- • WCAG compliant sizing
- • Cross-browser consistent
- • Recommended standard
Use Cases
Perfect for content areas, document viewers, list containers, and general-purpose scrolling.
Large (20px scrollbar)
Large Scrollbar
More prominent scrollbar for better visibility and easier interaction.
- • Prominent 20px scrollbar width
- • Excellent visibility
- • Very easy to target
- • Great for touch interfaces
- • Accessibility-focused
- • Clear visual feedback
- • Good for presentations
- • High contrast option
Big (24px scrollbar)
Big Scrollbar
Maximum visibility and easiest interaction for accessibility.
- • Extra large 24px scrollbar width
- • Maximum visibility
- • Easiest to interact with
- • Perfect for accessibility needs
- • Touch-optimized design
- • High DPI screen friendly
- • Kiosk mode interfaces
- • Senior-friendly design
Style Variants
Default Style (White Background)
Default Style
Clean white background with light gray scrollbar. Most commonly used for content areas.
- • White background (##ffffff)
- • Light gray scrollbar (##ebebeb)
- • Subtle hover effect
- • Clean appearance
- • Most common style
- • Professional look
- • High contrast text
- • Easy to read
Subtle Style (Gray Background)
Subtle Style
Soft gray background with darker scrollbar. Great for sidebars and secondary content.
- • Gray background (##f7f7f7)
- • Darker gray scrollbar (##d1d1d1)
- • More prominent hover
- • Minimalistic design
- • Less distracting
- • Good for sidebars
- • Blends with UI
- • Modern aesthetic
Horizontal Scrolling
Horizontal Scroll with Cards
Card 1
Horizontal scrolling example with cards.
Card 2
Scroll horizontally to see more cards.
Card 3
Great for image galleries and carousels.
Card 4
Supports touch gestures on mobile.
Card 5
Smooth scrolling with momentum.
Card 6
Last card in this example.
Container-Level Inheritance
Using .scrolls Container
Inherited Small + Subtle
This scroll inherits small size and subtle style from the parent .scrolls container.
- • No classes needed on children
- • Consistent styling across group
- • Easy to maintain
- • DRY principle
Also Inherited
This scroll also inherits the same properties automatically.
- • Same size and style
- • No duplication needed
- • Clean markup
- • Scalable approach
Size & Style Configuration
Available size and style modifiers:
tiny, small, default (no class), large, bigsubtlehorizontal<div class="scrolls [size] [style]"> - Children inherit propertiesNote: Scroll containers require a fixed max-height (vertical) or width (horizontal) to enable scrolling.
JavaScript API
// Create scroll programmatically
const scroll = hygge.scroll.create({
content: '<p>Dynamic content</p>',
size: 'small',
style: 'subtle',
maxHeight: '300px',
parent: document.body
});
// Scroll to specific position
hygge.scroll.scrollTo(scroll, 100, true);
// Scroll to element within container
const element = scroll.querySelector('.target');
hygge.scroll.scrollToElement(scroll, element, true);
// Get scroll information
const info = hygge.scroll.getInfo(scroll);
console.log(info.percentage); // Current scroll percentage
console.log(info.position); // Current scroll position
console.log(info.max); // Maximum scroll position
console.log(info.isScrollable); // Whether content is scrollable
// Access data attributes
console.log(scroll.dataset.scrollPosition); // "0" to "100"
console.log(scroll.dataset.scrollable); // "true" or "false"
Accessibility
- ✓ Keyboard navigation: Use arrow keys to scroll within focused containers
- ✓ Focus indicators: Blue outline appears when container receives focus
- ✓ Reduced motion: Respects
prefers-reduced-motionfor smooth scrolling - ✓ Touch support: iOS momentum scrolling with
-webkit-overflow-scrolling - ✓ Screen readers: Native scroll behavior preserved for assistive technology
- ✓ Dark mode: Automatic color adjustments via
prefers-color-scheme - ✓ Cross-browser: Supports both Webkit and Firefox scrollbar styling