Overview
TheHeroSlider component displays a full-screen hero section with rotating slides. Each slide features a large background image with a Ken Burns zoom effect, overlay text, and customizable alignment. The slider automatically rotates every 6 seconds and includes navigation controls.
Import
Props
Array of slide objects. If empty or not provided, displays three default slides showcasing PROVESA’s services.Slide Structure:
Usage
With Database Slides
With Custom Slides
Default Behavior (No Slides Provided)
Default Slides
When no slides are provided, the component shows three built-in slides:-
Slide 1 - Distribution (left-aligned)
- Title: “El pulso de la distribución”
- Badge: “Solidez desde 2006”
- Highlight: Yellow accent
-
Slide 2 - Infrastructure (right-aligned)
- Title: “Infraestructura Clase A”
- Highlight: Primary color
-
Slide 3 - Quality (center-aligned)
- Title: “Calidad en cada detalle”
- Highlight: Red accent
Features
Automatic Rotation
Slides automatically advance every 6 seconds:Ken Burns Effect
Each active slide has a slow zoom animation:Slide-In Animations
Content elements fade and slide up when the slide becomes active:- Badge: 0.3s delay
- Title: 0.15s delay
- Description: 0.45s delay
Navigation Controls
The slider includes multiple navigation methods:-
Navigation Dots (bottom center)
- Clicking jumps to specific slide
- Active dot is wider and has a pulse effect
- Only visible if there’s more than one slide
-
Arrow Buttons (left/right sides)
- Previous/Next slide buttons
- Only visible if there’s more than one slide
- Uses
ChevronsLeftandChevronsRighticons
-
Automatic Advance
- Slides change every 6 seconds
Text Alignment
Slides support three alignment options via thealign property:
Left Alignment
- Text aligned to left side
- Content positioned on left side of screen
Right Alignment
- Text aligned to right side
- Content positioned on right side with
ml-auto
Center Alignment
- Text centered
- Content centered with
mx-auto
Overlay Gradients
Each slide features layered gradients for better text readability:Dimensions
- Full viewport height
- Maximum 900px on large screens
- Minimum 600px to ensure content visibility
Transition States
The component tracks transition state to prevent rapid slide changes:Badge Component
Optional badge above the title:Accessibility
- Arrow buttons include
aria-labelattributes - Navigation dots include
aria-labelwith slide numbers - Section has semantic
id="inicio"for anchor navigation - Images include alt text with slide information
Real-World Example
Fromroutes/+page.svelte:
+page.server.js load function.
Performance Notes
- Only the active slide applies the Ken Burns animation
- Inactive slides are scaled to 1.05 for smooth transitions
- Z-index layering ensures proper stacking during transitions
- Images are loaded upfront (all slides rendered but hidden)
Dependencies
lucide-svelte- ChevronsLeft, ChevronsRight iconssvelte- onMount lifecycle function
Related Components
- Navbar - Often used with
transparent={true}over the slider - ProductSection - Typically follows the hero slider
