glide-react 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +190 -0
- package/dist/index.d.mts +651 -0
- package/dist/index.d.ts +651 -0
- package/dist/index.js +2043 -0
- package/dist/index.mjs +1994 -0
- package/package.json +75 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Coozywana
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# glide-react
|
|
2
|
+
|
|
3
|
+
A modern, minimalistic, lightweight React carousel component built with TypeScript, hooks, and functional components.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- đ¯ **TypeScript First** - Full type safety with strict interfaces
|
|
8
|
+
- ⥠**Modern React** - Built with hooks and functional components
|
|
9
|
+
- đ **Infinite Scrolling** - Seamless looping with clone-based approach
|
|
10
|
+
- đą **Touch/Swipe Support** - Native touch gestures for mobile
|
|
11
|
+
- đ¨ **CSS-in-JS Ready** - Inline styles for critical layout, customizable via className
|
|
12
|
+
- đĨī¸ **SSR/Next.js Compatible** - Hydration-safe with fallback rendering
|
|
13
|
+
- đĒļ **Lightweight** - No external dependencies beyond React
|
|
14
|
+
- đĻ **Small Bundle** - ~50KB ESM bundle
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install glide-react
|
|
20
|
+
# or
|
|
21
|
+
yarn add glide-react
|
|
22
|
+
# or
|
|
23
|
+
pnpm add glide-react
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import Glide from 'glide-react';
|
|
30
|
+
|
|
31
|
+
function MyCarousel() {
|
|
32
|
+
return (
|
|
33
|
+
<Glide
|
|
34
|
+
slidesToShow={3}
|
|
35
|
+
slidesToScroll={1}
|
|
36
|
+
infinite={true}
|
|
37
|
+
dots={true}
|
|
38
|
+
arrows={true}
|
|
39
|
+
>
|
|
40
|
+
<div>Slide 1</div>
|
|
41
|
+
<div>Slide 2</div>
|
|
42
|
+
<div>Slide 3</div>
|
|
43
|
+
<div>Slide 4</div>
|
|
44
|
+
<div>Slide 5</div>
|
|
45
|
+
</Glide>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Props
|
|
51
|
+
|
|
52
|
+
### Core Settings
|
|
53
|
+
|
|
54
|
+
| Prop | Type | Default | Description |
|
|
55
|
+
|------|------|---------|-------------|
|
|
56
|
+
| `slidesToShow` | `number` | `1` | Number of slides visible at once |
|
|
57
|
+
| `slidesToScroll` | `number` | `1` | Number of slides to scroll per navigation |
|
|
58
|
+
| `infinite` | `boolean` | `true` | Enable infinite loop scrolling |
|
|
59
|
+
| `speed` | `number` | `500` | Transition duration in milliseconds |
|
|
60
|
+
| `autoplay` | `boolean` | `false` | Auto-advance slides |
|
|
61
|
+
| `autoplaySpeed` | `number` | `3000` | Autoplay interval in milliseconds |
|
|
62
|
+
| `dots` | `boolean` | `false` | Show dot indicators |
|
|
63
|
+
| `arrows` | `boolean` | `true` | Show prev/next arrows |
|
|
64
|
+
| `fade` | `boolean` | `false` | Use fade effect instead of sliding |
|
|
65
|
+
| `vertical` | `boolean` | `false` | Vertical slide mode |
|
|
66
|
+
| `centerMode` | `boolean` | `false` | Center the active slide |
|
|
67
|
+
| `centerPadding` | `string` | `'50px'` | Side padding in center mode |
|
|
68
|
+
| `rtl` | `boolean` | `false` | Right-to-left mode |
|
|
69
|
+
|
|
70
|
+
### Callbacks
|
|
71
|
+
|
|
72
|
+
| Prop | Type | Description |
|
|
73
|
+
|------|------|-------------|
|
|
74
|
+
| `beforeChange` | `(current, next) => void` | Called before slide change |
|
|
75
|
+
| `afterChange` | `(current) => void` | Called after slide change |
|
|
76
|
+
| `onInit` | `() => void` | Called on slider initialization |
|
|
77
|
+
| `onSwipe` | `(direction) => void` | Called on swipe end |
|
|
78
|
+
|
|
79
|
+
### Customization
|
|
80
|
+
|
|
81
|
+
| Prop | Type | Default | Description |
|
|
82
|
+
|------|------|---------|-------------|
|
|
83
|
+
| `className` | `string` | `''` | Additional CSS class |
|
|
84
|
+
| `dotsClass` | `string` | `'glide-dots'` | Dots container class |
|
|
85
|
+
| `prevArrow` | `ReactElement` | `null` | Custom previous arrow |
|
|
86
|
+
| `nextArrow` | `ReactElement` | `null` | Custom next arrow |
|
|
87
|
+
| `customPaging` | `(i) => ReactElement` | `null` | Custom dot renderer |
|
|
88
|
+
| `appendDots` | `(dots) => ReactElement` | `null` | Custom dots container |
|
|
89
|
+
|
|
90
|
+
## Ref Methods
|
|
91
|
+
|
|
92
|
+
Access slider methods via ref:
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
import { useRef } from 'react';
|
|
96
|
+
import Glide, { GlideRef } from 'glide-react';
|
|
97
|
+
|
|
98
|
+
function MyCarousel() {
|
|
99
|
+
const sliderRef = useRef<GlideRef>(null);
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<>
|
|
103
|
+
<button onClick={() => sliderRef.current?.prev()}>
|
|
104
|
+
Previous
|
|
105
|
+
</button>
|
|
106
|
+
<button onClick={() => sliderRef.current?.next()}>
|
|
107
|
+
Next
|
|
108
|
+
</button>
|
|
109
|
+
<button onClick={() => sliderRef.current?.goTo(0)}>
|
|
110
|
+
Go to first
|
|
111
|
+
</button>
|
|
112
|
+
|
|
113
|
+
<Glide ref={sliderRef}>
|
|
114
|
+
{/* slides */}
|
|
115
|
+
</Glide>
|
|
116
|
+
</>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Available Methods
|
|
122
|
+
|
|
123
|
+
| Method | Description |
|
|
124
|
+
|--------|-------------|
|
|
125
|
+
| `prev()` | Go to previous slide |
|
|
126
|
+
| `next()` | Go to next slide |
|
|
127
|
+
| `goTo(index, dontAnimate?)` | Go to specific slide |
|
|
128
|
+
| `pause()` | Pause autoplay |
|
|
129
|
+
| `play()` | Start autoplay |
|
|
130
|
+
|
|
131
|
+
## Responsive Settings
|
|
132
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
<Glide
|
|
135
|
+
slidesToShow={4}
|
|
136
|
+
responsive={[
|
|
137
|
+
{
|
|
138
|
+
breakpoint: 1024,
|
|
139
|
+
settings: {
|
|
140
|
+
slidesToShow: 3,
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
breakpoint: 768,
|
|
145
|
+
settings: {
|
|
146
|
+
slidesToShow: 2,
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
breakpoint: 480,
|
|
151
|
+
settings: {
|
|
152
|
+
slidesToShow: 1,
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
]}
|
|
156
|
+
>
|
|
157
|
+
{/* slides */}
|
|
158
|
+
</Glide>
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Custom Arrows
|
|
162
|
+
|
|
163
|
+
```tsx
|
|
164
|
+
function CustomPrevArrow({ onClick }) {
|
|
165
|
+
return <button onClick={onClick}>â</button>;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function CustomNextArrow({ onClick }) {
|
|
169
|
+
return <button onClick={onClick}>â</button>;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
<Glide
|
|
173
|
+
prevArrow={<CustomPrevArrow />}
|
|
174
|
+
nextArrow={<CustomNextArrow />}
|
|
175
|
+
>
|
|
176
|
+
{/* slides */}
|
|
177
|
+
</Glide>
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Styling
|
|
181
|
+
|
|
182
|
+
The component uses inline styles for critical layout. You can customize appearance via:
|
|
183
|
+
|
|
184
|
+
1. **className prop** - Add your own classes
|
|
185
|
+
2. **Built-in class names** - Style `.glide-slider`, `.glide-track`, `.glide-slide`, `.glide-arrow`, `.glide-dots`, etc.
|
|
186
|
+
3. **Custom components** - Use `prevArrow`, `nextArrow`, `customPaging`, `appendDots`
|
|
187
|
+
|
|
188
|
+
## License
|
|
189
|
+
|
|
190
|
+
MIT
|