simple-image-carousel v1.2.5
simple-image-carousel Demo WebSite
Install
npm i simple-image-carousel
Languages
π°π· Korea
πΊπΈ English
Korea
μ΄λ―Έμ§ μ¬λΌμ΄λλ κΈ°λ³Έμ μΌλ‘ lazy loadingμ μ§μνμ¬, μ€ν¬λ‘€ μμ μ μ΄λ―Έμ§λ₯Ό λ‘λν©λλ€.
| Props | μ€λͺ
| κΈ°λ³Έκ° | νμ
|
|---------------------|----------------------------------------------------------------------------|--------------------|---------------------|
| images | { url: string }
νμμ κ°μ²΄ λ°°μ΄λ‘, μ¬λΌμ΄λμ νμν μ΄λ―Έμ§ URLμ ν¬ν¨ν©λλ€. | - | { url: string }[] |
| showArrows | μ¬λΌμ΄λ μ μμ νμ΄νλ₯Ό νμν μ§ μ¬λΆλ₯Ό μ€μ ν©λλ€. | true | boolean |
| showDots | μ¬λΌμ΄λ νλ¨μ μ μ νμν μ§ μ¬λΆλ₯Ό μ€μ ν©λλ€. | true | boolean |
| enableDrag | λλκ·Έ κΈ°λ₯μ νμ±νν μ§ μ¬λΆλ₯Ό μ€μ ν©λλ€. | true | boolean |
| enableLoop | μ¬λΌμ΄λμ 루ν κΈ°λ₯μ νμ±νν μ§ μ¬λΆλ₯Ό μ€μ ν©λλ€. μλ μ¬λΌμ΄λκ° νμ±ν λΌμμΌλ©΄ ν΄λΉ κ°μ trueκ° λ©λλ€. | true | boolean |
| width | μ¬λΌμ΄λμ λλΉλ₯Ό μ€μ ν©λλ€. | null | number | null |
| height | μ¬λΌμ΄λμ λμ΄λ₯Ό μ€μ ν©λλ€. | null | number | null |
| objectFit | μ΄λ―Έμ§λ₯Ό λ§μΆλ λ°©μμ μ€μ ν©λλ€. | fill | "fill" | "contain" | "cover" | "none" | "scale-down" |
| dotColor | μ μ μμμ μ€μ ν©λλ€. | rgb(0, 114, 255) | string |
| dotHoverColor | μ μ λ§μ°μ€λ‘ κ°λ¦¬ν¬ λμ μμμ μ€μ ν©λλ€. | rgb(135, 135, 135) | string |
| dotBorderColor | μ μ ν
λ리 μμμ μ€μ ν©λλ€. | rgb(152, 152, 152) | string |
| arrowColor | νμ΄νμ μμμ μ€μ ν©λλ€. | white | string |
| arrowSize | νμ΄νμ ν¬κΈ°λ₯Ό μ€μ ν©λλ€. | 50 | number |
| dotSize | μ μ ν¬κΈ°λ₯Ό μ€μ ν©λλ€. | 13 | number |
| borderRadius | μ¬λΌμ΄λμ λͺ¨μ리 λ°κ²½μ μ€μ ν©λλ€. | 0 | number |
| autoSlider | μλ μ¬λΌμ΄λ μκ°(λ°λ¦¬μ΄)μ μ€μ ν©λλ€. | 0 | number |
| duration | μ¬λΌμ΄λ μ λλ©μ΄μ
μ§μ μκ°(λ°λ¦¬μ΄)μ μ€μ ν©λλ€. | 300 | number |
μ¬μ© μμ
import React from 'react';
import ImageSlider from 'simple-image-carousel';
const images = [
{ url: 'https://example.com/image1.jpg' },
{ url: 'https://example.com/image2.jpg' },
{ url: 'https://example.com/image3.jpg' },
];
const App = () => (
{/* λμ΄λ₯Ό μ§μ ν΄ μ£Όμ§ μμΌλ©΄ κΈ°λ³Έμ μΌλ‘ λΆλͺ¨ ν¬κΈ°μ 100%λ₯Ό μ°¨μ§ν©λλ€ */}
<div>
<ImageSlider images={images} />
</div>
{/* μλμ κ°μ propsλ₯Ό μ¬μ©ν μ μμ΅λλ€. */}
<div>
<ImageSlider
images={images}
showArrows={true}
showDots={true}
enableDrag={true}
enableLoop={true}
width={600}
height={400}
objectFit="cover"
dotColor="blue"
dotHoverColor="lightblue"
dotBorderColor="darkblue"
dotSize={20}
arrowColor="black"
arrowSize={40}
borderRadius={10}
autoSlider={3000}
duration={500}
/>
</div>
);
export default App;
NextJSμ ν¨κ» μ¬μ©
import dynamic from "next/dynamic";
const ImageSlider = dynamic(() => import("simple-image-carousel"), {
ssr: false,
});
English
The image slider supports lazy loading by default, loading images as they come into view during scrolling.
| Props | Description | Default | Type |
|---------------------|----------------------------------------------------------------------------|--------------------|---------------------|
| images | An array of objects { url: string }
containing image URLs to be displayed in the slider. | - | { url: string }[] |
| showArrows | Determines whether arrows are shown on the sides of the slider. | true | boolean |
| showDots | Determines whether dots are shown at the bottom of the slider. | true | boolean |
| enableDrag | Enables or disables the drag functionality. | true | boolean |
| enableLoop | Enables or disables the loop functionality of the slider. If auto slider is enabled, this value will be set to true. | true | boolean |
| width | Sets the width of the slider. | null | number | null |
| height | Sets the height of the slider. | null | number | null |
| objectFit | Sets the object fit mode for the images. | fill | "fill" | "contain" | "cover" | "none" | "scale-down" |
| dotColor | Sets the color of the dots. | rgb(0, 114, 255) | string |
| dotHoverColor | Sets the color of the dots when hovered over. | rgb(135, 135, 135) | string |
| dotBorderColor | Sets the border color of the dots. | rgb(152, 152, 152) | string |
| arrowColor | Sets the color of the arrows. | white | string |
| arrowSize | Sets the size of the arrows. | 50 | number |
| dotSize | Sets the size of the dots. | 13 | number |
| borderRadius | Sets the border radius of the slider. | 0 | number |
| autoSlider | Sets the automatic slider interval time in milliseconds. | 0 | number |
| duration | Sets the duration of the slide animation in milliseconds. | 300 | number |
Example Usage
import React from 'react';
import ImageSlider from 'simple-image-carousel';
const images = [
{ url: 'https://example.com/image1.jpg' },
{ url: 'https://example.com/image2.jpg' },
{ url: 'https://example.com/image3.jpg' },
];
const App = () => (
{/* If you don't specify a width, it defaults to 100% of the parent's size */}
<div>
<ImageSlider images={images} />
</div>
{/* You can use the following props */}
<div>
<ImageSlider
images={images}
showArrows={true}
showDots={true}
enableDrag={true}
enableLoop={true}
width={600}
height={400}
objectFit="cover"
dotColor="blue"
dotHoverColor="lightblue"
dotBorderColor="darkblue"
dotSize={20}
arrowColor="black"
arrowSize={40}
borderRadius={10}
autoSlider={3000}
duration={500}
/>
</div>
);
export default App;
with NextJS
import dynamic from "next/dynamic";
const ImageSlider = dynamic(() => import("simple-image-carousel"), {
ssr: false,
});