Carousel ❓
이미지 슬라이더(?)의 정식명칭은 캐러셀이다.
슬라이드쇼와 같은 방식으로 콘텐츠를 표시하는 UX 구성 요소이다. 아래 링크로 들어가면 다양한 carousel을 볼 수 있다.
https://ant.design/components/carousel
Carousel - Ant Design
A carousel component. Scales with its container. When To Use When there is a group of content on the same level.When there is insufficient content space, it can be used to save space in the form of a revolving door.Commonly used for a group of pictures/car
ant.design
이전에 React에서 carousel을 구현할 때 react slick 이라는 라이브러리를 사용했는데, 비슷한 라이브러리가 또 있다.
바로 Swiper !
📌 설치
npm을 통해 설치한다.
npm i swiper
📌 데모 확인하기
튜토리얼 상단에서 Demo를 클릭하면 굉장히 다양한 carousel이 나온다. (react slick에 비해 굉장히 다양함)
Swiper Demos
Swiper is the most modern free mobile touch slider with hardware accelerated transitions and amazing native behavior.
swiperjs.com
📌 예시 코드
// Import Swiper React components
import { Swiper, SwiperSlide } from 'swiper/react';
// Import Swiper styles
import 'swiper/css';
export default () => {
return (
<Swiper
spaceBetween={50}
slidesPerView={3}
onSlideChange={() => console.log('slide change')}
onSwiper={(swiper) => console.log(swiper)}
>
<SwiperSlide>Slide 1</SwiperSlide>
<SwiperSlide>Slide 2</SwiperSlide>
<SwiperSlide>Slide 3</SwiperSlide>
<SwiperSlide>Slide 4</SwiperSlide>
...
</Swiper>
);
};
Swiper, SwiperSlide 컴포넌트를 Import하고 swiper/css 또한 Import한다.
🔗 참고 / Carousel 관련한 또다른 라이브러리 - react-slicka
https://react-slick.neostack.com/
Neostack
The last react carousel you will ever need
react-slick.neostack.com
🔗 출처
Swiper - The Most Modern Mobile Touch Slider
Swiper is the most modern free mobile touch slider with hardware accelerated transitions and amazing native behavior.
swiperjs.com
'개발일지 > React' 카테고리의 다른 글
[React 리액트] react-calendar - 캘린더 적용하기 (0) | 2023.02.02 |
---|---|
[React 리액트] react-icons - 인기 있는 Icon 쉽게 사용하기 (0) | 2023.02.02 |
[React 리액트] react-loading 라이브러리 - 로딩 스피너 만들기 (0) | 2023.02.02 |
[React 리액트] react-new-window 라이브러리 - 새로운 window창 띄우는 방법 (0) | 2022.12.28 |
[React 리액트] 파이어베이스 오류 Attempted import error: 'firebase/app' does not contain a default export (imported as 'firebase'). (0) | 2022.11.05 |