npx skills add ...
npx skills add freshtechbro/claudedesignskills --skill barba-js
Page transitions library for creating fluid, smooth transitions between website pages. Use this skill when implementing page transitions, creating SPA-like experiences, adding animated route changes, or building websites with smooth navigation. Triggers on tasks involving Barba.js, page transitions, routing, view management, transition hooks, GSAP integration, or smooth page navigation. Works with gsap-scrolltrigger for transition animations.
npx skills add freshtechbro/claudedesignskills --skill barba-js
Modern page transition library for creating fluid, smooth transitions between website pages. Barba.js makes multi-page websites feel like Single Page Applications (SPAs) by hijacking navigation and managing transitions without full page reloads.
Barba.js is a lightweight (7kb minified and compressed) JavaScript library that intercepts navigation between pages, fetches new content via AJAX, and smoothly transitions between old and new containers. It reduces page load delays and HTTP requests while maintaining the benefits of traditional multi-page architecture.
Core Features:
Barba.js uses a specific DOM structure to manage transitions:
HTML Structure:
Three Key Elements:
Wrapper (data-barba="wrapper")
Container (data-barba="container")
Namespace (data-barba-namespace="home")
Barba.js follows a precise lifecycle for each navigation:
Default Async Flow:
Sync Flow (with sync: true):
Barba provides 11 lifecycle hooks for controlling transitions:
Hook Execution Order:
Hook Types:
barba.hooks.before())Common Hook Use Cases:
beforeLeave - Reset scroll position, prepare animationsleave - Animate current page outafterLeave - Clean up old pagebeforeEnter - Prepare new page (hide elements, set initial states)enter - Animate new page inafterEnter - Initialize page scripts, analytics trackingViews are page-specific logic containers that run based on namespace:
Installation:
Minimal Configuration:
Classic fade-out, fade-in transition:
Simultaneous fade between pages:
Slide old page out, new page in with overlap:
Define different transitions based on navigation context:
Use @barba/router for route-specific transitions:
Installation:
Usage:
Show loading state during page fetch:
Barba.js works seamlessly with GSAP for animations:
Timeline-Based Transitions:
Reference gsap-scrolltrigger skill for advanced GSAP integration patterns.
Initialize libraries or scripts per page:
Track page views on navigation:
Re-run scripts after page transitions:
Use @barba/prefetch to load pages on hover:
Set container min-height to prevent content jump:
Use GPU-accelerated properties:
Remove listeners in beforeLeave or view hooks:
Defer image loading until after transition:
Problem: Transitions complete instantly without waiting for animations.
Solution: Always return promises or use async/await:
Problem: Some links cause full page reloads.
Solution: Barba automatically prevents default on internal links, but you may need to exclude external links:
Problem: Old page CSS affects new page layout during transition.
Solution: Use namespace-specific CSS or reset styles:
Or reset in beforeEnter:
Problem: Page title and meta tags don't update on navigation.
Solution: Use @barba/head plugin or update manually:
Or manually:
Problem: New page flashes visible before enter animation starts.
Solution: Set initial invisible state in CSS or beforeEnter:
Problem: Sync transitions cause layout shift as containers stack.
Solution: Position containers absolutely during transition:
Or manage in JavaScript:
This skill includes:
Executable utilities for common Barba.js tasks:
transition_generator.py - Generate transition boilerplate codeproject_setup.py - Initialize Barba.js project structureDetailed documentation:
api_reference.md - Complete Barba.js API (hooks, transitions, views, router)hooks_guide.md - All 11 hooks with execution order and use casesgsap_integration.md - GSAP animation patterns for Barba transitionstransition_patterns.md - Common transition implementationsTemplates and starter projects:
starter_barba/ - Complete Barba.js + GSAP starter templateexamples/ - Real-world transition implementations