Configs2026年7月21日·1 分钟阅读

Splide — Lightweight Accessible Slider and Carousel

A lightweight, flexible, and accessible slider/carousel library written in TypeScript with no dependencies, zero Lighthouse errors, and support for React, Vue, and Svelte.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Splide Overview
直接安装命令
npx -y tokrepo@latest install 4d9eea27-8548-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

Splide is a lightweight slider and carousel library that achieves zero Lighthouse errors out of the box. Written in TypeScript with no dependencies, it weighs under 30KB minified and provides touch/swipe support, autoplay, lazy loading, responsive breakpoints, and full keyboard/screen reader accessibility. Official integrations exist for React, Vue, and Svelte.

What Splide Does

  • Renders responsive sliders and carousels from a simple HTML structure
  • Supports horizontal, vertical, fade, and loop (infinite) slide transitions
  • Handles touch, swipe, mouse drag, and keyboard navigation natively
  • Provides autoplay with pause-on-hover and progress bar support
  • Offers lazy loading for images to improve page load performance

Architecture Overview

Splide is built around a component-based architecture internally, with each feature (Arrows, Pagination, Autoplay, LazyLoad, Keyboard) implemented as a mountable component. The core manages a state machine tracking the active slide index, transition state, and drag coordinates. It uses CSS transforms for smooth hardware-accelerated transitions and IntersectionObserver for lazy loading. The library emits events at every lifecycle point, allowing extension via custom components or the event API.

Self-Hosting & Configuration

  • Install via npm or include the CSS and JS from a CDN
  • Add the required HTML structure with splide, splide__track, splide__list, and splide__slide classes
  • Instantiate with new Splide('.splide', options).mount()
  • Configure via the options object: type, perPage, gap, autoplay, breakpoints
  • For React, use @splidejs/react-splide; for Vue, use @splidejs/vue-splide

Key Features

  • Fully accessible with ARIA attributes, keyboard navigation, and live region announcements
  • Multiple slide types: loop, fade, and slide with configurable per-page counts
  • Responsive breakpoints for adapting layout to different screen sizes
  • Extension system for adding features like video support, grid layouts, and URL hash navigation
  • Thumbnail slider synchronization via the sync API

Comparison with Similar Tools

  • Swiper — more feature-rich with 3D effects and virtual slides; Splide is smaller and simpler
  • Flickity — polished touch carousel with physics-based dragging; Splide has better accessibility defaults
  • Embla Carousel — headless, extensible carousel engine; Splide ships with styling and UI out of the box
  • Glide.js — lightweight ES6 slider; Splide offers richer TypeScript types and framework integrations

FAQ

Q: Does Splide affect Lighthouse scores? A: No. Splide is designed to achieve zero Lighthouse errors in performance, accessibility, best practices, and SEO categories.

Q: Can I create an infinite loop slider? A: Yes. Set type: 'loop' in the options to enable infinite looping where the last slide transitions seamlessly back to the first.

Q: How do I sync a thumbnail slider with a main slider? A: Create two Splide instances and call mainSlider.sync(thumbnailSlider).mount() before mounting the thumbnail slider.

Q: Does it support video slides? A: Yes, via the official @splidejs/splide-extension-video extension, which supports YouTube, Vimeo, and HTML5 video.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产