Slider Builder
Slider Builder
Build a fully functional interactive image slider using Swiper.js library with autoplay, navigation, and responsive design.
Prompt
How it works
Preparation
Verify Webflow Designer is connected, get the site ID, navigate to the target page, and plan slider placement and image sources.
Create DOM Structure
Use element_builder to create the complete slider structure including:
- Main swiper container with unique ID and class
- Link element for Swiper CSS library (CDN)
- Script element for Swiper JS library (CDN)
- Style element for custom CSS
- Swiper wrapper div for containing slides
- Pagination element for navigation dots
- Navigation buttons (previous/next arrows)
Add Custom CSS
Select the style element and use set_text action to add CSS rules for:
- Navigation button styling (colors, borders, shadows)
- Pagination dot styling
- Match the site’s design theme (minimal, neobrutalist, modern, etc.)
Write Initialization JavaScript
Use add_inline_site_script to create pure JavaScript code that:
- Finds the slider container and wrapper elements
- Clears existing content properly using removeChild loop
- Dynamically creates slide elements with images
- Implements retry logic to wait for Swiper library to load
- Initializes Swiper with configuration (autoplay, navigation, pagination)
- Handles errors gracefully with try-catch blocks
Key constraints
Critical Webflow Limitations:
- Custom code API accepts pure JavaScript only - no
<script>tags - External CSS/JS libraries must be loaded via DOM
<link>and<script>elements - Use retry logic when waiting for external libraries to load
- Clear wrapper content using removeChild loop, not innerHTML
- Always use unique IDs for slider containers to avoid conflicts
Customization options
Swiper Configuration
Customize slider behavior by modifying the Swiper initialization config:
slidesPerView: Number of slides visible at oncespaceBetween: Gap between slides in pixelsloop: Enable infinite loop modeautoplay.delay: Milliseconds between auto-advancespeed: Transition speed in millisecondseffect: Transition effect (‘slide’, ‘fade’, ‘cube’, ‘coverflow’, ‘flip’)direction: Slider direction (‘horizontal’ or ‘vertical’)
Styling Themes
Adapt the CSS based on your site’s design:
- Minimal: Simple arrows, minimal borders, neutral colors
- Neobrutalist: Bold borders, offset shadows, bright accent colors
- Modern: Smooth transitions, subtle shadows, rounded corners
- Glassmorphism: Transparent backgrounds with blur effects