Skip to content

Commit b284630

Browse files
Merge pull request Webflow-Examples#7 from viratatwebflow/cms-slider
added CMS Slider & README with features and integration details
2 parents eb2c127 + 77da5e3 commit b284630

24 files changed

Lines changed: 19905 additions & 0 deletions

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ A dynamic form generator demonstrating:
3535
- **Conditional logic** for showing/hiding fields
3636
- **Data persistence** across steps
3737

38+
### 🎠 [CMS Slider](./cms-slider/)
39+
40+
A carousel slider that integrates with Webflow CMS collections featuring:
41+
42+
- **CMS Collection Integration** extracts and displays items from Webflow CMS Collection list.
43+
- **React Slick** carousel with configurable options (autoplay, infinite loop, dots, arrows).
44+
- **Shadow DOM styling** for proper style isolation in Webflow Code Component.
45+
- **Slot-based content** accepts Webflow CMS collection lists as component slots.
46+
- **Customizable behavior** control slides to show, scroll speed, and autoplay settings.
47+
3848
### 🗺️ [Store Locator](./store-locator/)
3949

4050
A map component and backend API that plots locations demonstrating:

cms-slider/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

cms-slider/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# CMS Slider
2+
3+
This code component example is a carousel slider that integrates seamlessly with Webflow CMS collections, allowing you to display dynamic CMS content in an interactive slider format. [See a live example here.](https://cms-slider-4d63c4.webflow.io/)
4+
5+
![](./screenshot/preview-1.png)
6+
7+
## Features
8+
9+
- **CMS Collection Integration** - Automatically extracts and displays items from Webflow CMS Collection lists via slot-based architecture
10+
- **React Slick Carousel** - Powered by React Slick with full carousel functionality
11+
- **Configurable Behavior** - Control slides to show, scroll speed, infinite looping, autoplay, navigation arrows, and dots
12+
- **Slot-Based Content** - Accepts any Webflow CMS collection list as a component slot for maximum flexibility
13+
- **Vite Project Setup** - Fast development experience with Hot Module Replacement (HMR)
14+
15+
## Getting Started
16+
17+
- Install dependencies: `npm i`
18+
- Run `npx webflow library share` to create a code library for this example in your designated Webflow workspace
19+
20+
## Component Properties
21+
22+
| Prop Name | Type | Default | Description |
23+
| ---------------------------- | --------- | ------- | ------------------------------------------------------------ |
24+
| `cmsCollectionComponentSlot` | `Slot` | - | The slot where you place your Webflow CMS Collection List |
25+
| `showCMSCollectionComponent` | `Boolean` | `false` | Toggle visibility of the CMS collection for editing purposes |
26+
| `infinite` | `Boolean` | `true` | Enable infinite looping of slides |
27+
| `slidesToShow` | `Number` | `1` | Number of slides visible at once |
28+
| `slidesToScroll` | `Number` | `1` | Number of slides to scroll on navigation |
29+
| `dots` | `Boolean` | `true` | Show navigation dots below the slider |
30+
| `arrows` | `Boolean` | `true` | Show previous/next navigation arrows |
31+
| `autoplay` | `Boolean` | `true` | Enable automatic slide transitions |
32+
| `autoplaySpeed` | `Number` | `3000` | Delay between auto transitions (in milliseconds) |
33+
34+
## Technical Implementation
35+
36+
This component showcases several advanced patterns for Webflow Code Components:
37+
38+
- **Custom Hook (`useCMSCollectionItems`)** - Extracts CMS list items from Webflow slots using Shadow DOM slot APIs
39+
- **Shadow DOM Style Injection** - Uses `useShadowGlobalStyles` hook to inject Webflow styles into the shadow root
40+
- **Element Cloning** - Clones CMS elements to render them within the slider while preserving their Webflow styling
41+
- **React Slick Integration** - Demonstrates how to integrate third-party React libraries with Webflow Code Components

cms-slider/eslint.config.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import js from '@eslint/js'
2+
import globals from 'globals'
3+
import reactHooks from 'eslint-plugin-react-hooks'
4+
import reactRefresh from 'eslint-plugin-react-refresh'
5+
import tseslint from 'typescript-eslint'
6+
import { defineConfig, globalIgnores } from 'eslint/config'
7+
8+
export default defineConfig([
9+
globalIgnores(['dist']),
10+
{
11+
files: ['**/*.{ts,tsx}'],
12+
extends: [
13+
js.configs.recommended,
14+
tseslint.configs.recommended,
15+
reactHooks.configs['recommended-latest'],
16+
reactRefresh.configs.vite,
17+
],
18+
languageOptions: {
19+
ecmaVersion: 2020,
20+
globals: globals.browser,
21+
},
22+
},
23+
])

cms-slider/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>cms-slider</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/main.tsx"></script>
12+
</body>
13+
</html>

0 commit comments

Comments
 (0)