react-alice-carousel、react-image-gallery、react-responsive-carousel、react-slick は、React アプリケーションでスライドショーやカルーセルを実装するための主要なライブラリです。それぞれ目的が異なり、react-slick は伝統的な多機能カルーセル、react-responsive-carousel は軽量で SSR に強く、react-image-gallery は画像専用のライトボックス機能に特化、react-alice-carousel はタッチ操作とレスポンシブ設計に優れています。開発者はプロジェクトの要件に応じて、依存関係、SSR 対応、カスタマイズ性を選択基準にする必要があります。
react-alice-carousel、react-image-gallery、react-responsive-carousel、react-slick は、React アプリケーションでスライドショーやカルーセルを実装するための主要なライブラリですが、内部構造と得意分野が異なります。それぞれの違いを理解し、プロジェクトに最適な選択をするために、技術的な観点から比較します。
ライブラリの選定では、依存関係の重さと CSS の扱いが重要です。外部ライブラリに依存しすぎると、バンドルサイズが増えたり、スタイルの競合が起きたりします。
react-slick は、元の jQuery プラグインである slick-carousel に依存しています。
// react-slick
import Slider from "react-slick";
import "slick-carousel/slick/slick.css";
import "slick-carousel/slick/slick-theme.css";
function App() {
return <Slider>{items}</Slider>;
}
react-responsive-carousel は依存関係が少なく、独自の CSS をインポートします。
// react-responsive-carousel
import { Carousel } from 'react-responsive-carousel';
import "react-responsive-carousel/lib/styles/carousel.min.css";
function App() {
return <Carousel>{items}</Carousel>;
}
react-image-gallery は画像表示に特化しており、独自のスタイルシートが必要です。
// react-image-gallery
import ImageGallery from 'react-image-gallery';
import "react-image-gallery/styles/css/image-gallery.css";
function App() {
return <ImageGallery items={items} />;
}
react-alice-carousel は純粋な React 実装に近いです。
// react-alice-carousel
import AliceCarousel from 'react-alice-carousel';
import 'react-alice-carousel/lib/alice-carousel.css';
function App() {
return <AliceCarousel>{items}</AliceCarousel>;
}
各ライブラリは、データ構造とコンポーネントの使い方が異なります。特に、子要素の扱いと設定 props の違いに注意が必要です。
react-slick は設定オブジェクトを使って動作を制御します。
settings オブジェクトに矢印表示や autoplay などを定義します。Slider コンポーネント内に配置します。// react-slick
const settings = {
dots: true,
infinite: true,
speed: 500,
slidesToShow: 1
};
<Slider {...settings}>
<div><h3>1</h3></div>
<div><h3>2</h3></div>
</Slider>
react-responsive-carousel は props で機能をオンオフします。
Carousel コンポーネント内に配置します。// react-responsive-carousel
<Carousel showArrows={true} infiniteLoop={true}>
<div><img src="1.jpg" /></div>
<div><img src="2.jpg" /></div>
</Carousel>
react-image-gallery は専用のデータ構造を要求します。
items 配列にオブジェクトを渡す形式です。// react-image-gallery
const items = [
{ original: "1.jpg", thumbnail: "1_thumb.jpg" },
{ original: "2.jpg", thumbnail: "2_thumb.jpg" }
];
<ImageGallery items={items} />
react-alice-carousel は子要素または items プロパティを使います。
responsive プロパティで挙動を制御できます。// react-alice-carousel
const items = [
<div>1</div>,
<div>2</div>
];
<AliceCarousel items={items} disableDotsControls />
モバイル対応では、画面サイズに応じて表示するアイテム数を変える必要があります。ここで各ライブラリの設計思想がはっきりと分かれます。
react-slick は responsive 配列でブレークポイントを定義します。
// react-slick
const settings = {
responsive: [
{
breakpoint: 1024,
settings: { slidesToShow: 3 }
},
{
breakpoint: 600,
settings: { slidesToShow: 1 }
}
]
};
react-responsive-carousel は CSS ベースの対応が基本です。
// react-responsive-carousel
// CSS で容器の幅を制御するのが一般的
<div style={{ width: '100%', maxWidth: '600px' }}>
<Carousel>
<div>Item 1</div>
</Carousel>
</div>
react-image-gallery はギャラリー構造に最適化されています。
// react-image-gallery
// 基本的には単一画像表示がメイン
<ImageGallery
items={items}
slideOnThumbnailOver={true}
/>
react-alice-carousel はオブジェクト形式でレスポンシブを定義します。
// react-alice-carousel
const responsive = {
0: { items: 1 },
720: { items: 3 },
1024: { items: 5 }
};
<AliceCarousel responsive={responsive} />
Next.js などのサーバーサイドレンダリング環境では、window オブジェクトへのアクセスエラーに注意が必要です。
react-slick は SSR 設定に注意が必要です。
ssr: true を設定に含める必要があります。// react-slick (Next.js example)
const Slider = dynamic(() => import("react-slick"), { ssr: false });
// または settings に ssr: true を追加
react-responsive-carousel は SSR に強く設計されています。
// react-responsive-carousel
// 特別な SSR 設定は不要な場合が多い
<Carousel>
<div>Content</div>
</Carousel>
react-image-gallery も SSR に対応しています。
// react-image-gallery
// 標準的に SSR 対応
<ImageGallery items={items} />
react-alice-carousel は SSR をサポートしています。
// react-alice-carousel
// SSR 環境でも動作するように設計されている
<AliceCarousel items={items} />
画像を扱う場合、ライトボックスやサムネイル機能の有無が重要な分岐点になります。
react-slick は汎用カルーセルです。
// react-slick
// ライトボックスには別のライブラリが必要
<Slider>
<img src="photo.jpg" onClick={openLightbox} />
</Slider>
react-responsive-carousel も汎用カルーセルです。
// react-responsive-carousel
// 画像表示は可能だが機能はシンプル
<Carousel>
<div><img src="photo.jpg" /></div>
</Carousel>
react-image-gallery はこの機能に特化しています。
// react-image-gallery
// クリックで拡大表示が標準
<ImageGallery items={items} />
react-alice-carousel は汎用ですがカスタマイズ可能です。
// react-alice-carousel
// カスタム実装が必要
<AliceCarousel>
<img src="photo.jpg" onClick={handleClick} />
</AliceCarousel>
| 特徴 | react-slick | react-responsive-carousel | react-image-gallery | react-alice-carousel |
|---|---|---|---|---|
| 依存関係 | slick-carousel (CSS/JS) | 軽量 (独自 CSS) | 独自 CSS (画像特化) | 軽量 (独自 CSS) |
| SSR 対応 | 設定必要 (dynamic import) | 良好 | 良好 | 良好 |
| レスポンシブ | 配列で詳細設定 | CSS 依存 | 画像サイズ調整 | オブジェクトで設定 |
| 画像機能 | 汎用 (ライトボックス別) | 汎用 (シンプル) | 特化 (ライトボックス内蔵) | 汎用 (カスタマイズ可) |
| 保守状況 | 更新頻度は低め | 活発 | 活発 | 活発 |
react-slick は機能豊富ですが、依存関係と SSR 設定の重さを許容できる場合に限り検討します。既存の Slick デザインを維持したいレガシープロジェクト向きです。
react-responsive-carousel は、SSR を重視し、シンプルで軽量なカルーセルが必要な場合に最適です。余計な機能 없이 安定した動作を求めるときに選定します。
react-image-gallery は、画像専用のギャラリー(ライトボックス、サムネイル)が必要な場合に一択です。汎用カルーセルとして使おうとすると制限が多くなります。
react-alice-carousel は、モダンな React プロジェクトで、タッチ操作とレスポンシブ設定をバランスよく求めている場合に推奨します。設定が直感的で、カスタマイズもしやすいです。
最終的には、プロジェクトが「画像ギャラリー」を必要としているか、「汎用スライダー」を必要としているかで最初に絞り込み、その後に SSR やレスポンシブ要件で決定するのが賢明です。
画像専用のギャラリー機能(サムネイル、ライトボックス、フルスクリーン表示)が必要な場合に選択します。一般的なコンテンツカルーセルではなく、写真ポートフォリオや製品画像表示に特化しています。追加のカスタマイズなしで高機能な画像表示を実現できます。
タッチ操作への対応や細かいレスポンシブ制御が必要な場合に選択します。ブレークポイントに基づくアイテム数の変更が簡単で、モダンな React プロジェクトに適しています。依存関係が少なく、純粋な React 構成で動作させたいチームに向いています。
サーバーサイドレンダリング(SSR)を重視し、軽量なソリューションが必要な場合に選択します。設定がシンプルで、CSS によるカスタマイズが容易です。複雑な機能よりも安定性とパフォーマンスを優先するプロジェクトに適しています。
豊富な機能と設定オプションが必要で、既存の Slick Carousel デザインを継承したい場合に選択します。ただし、jQuery 由来の CSS 依存関係があり、SSR 設定に追加の工夫が必要です。レガシーシステムからの移行や、多機能なスライダーが必要な場合に検討します。
A responsive, customizable image gallery component for React

| Feature | Description |
|---|---|
| 📱 Mobile Swipe | Native touch gestures for smooth mobile navigation |
| 🖼️ Thumbnails | Customizable thumbnail navigation with multiple positions |
| 📺 Fullscreen | Browser fullscreen or CSS-based fullscreen modes |
| 🎨 Theming | CSS custom properties for easy styling |
| ⌨️ Keyboard Nav | Arrow keys, escape, and custom key bindings |
| 🔄 RTL Support | Right-to-left language support |
| ↕️ Vertical Mode | Slide vertically instead of horizontally |
| 🎬 Custom Slides | Render videos, iframes, or any custom content |
npm install react-image-gallery
import { useRef } from "react";
import ImageGallery from "react-image-gallery";
import "react-image-gallery/styles/image-gallery.css";
import type { GalleryItem, ImageGalleryRef } from "react-image-gallery";
const images: GalleryItem[] = [
{
original: "https://picsum.photos/id/1018/1000/600/",
thumbnail: "https://picsum.photos/id/1018/250/150/",
},
{
original: "https://picsum.photos/id/1015/1000/600/",
thumbnail: "https://picsum.photos/id/1015/250/150/",
},
{
original: "https://picsum.photos/id/1019/1000/600/",
thumbnail: "https://picsum.photos/id/1019/250/150/",
},
];
function MyGallery() {
const galleryRef = useRef<ImageGalleryRef>(null);
return (
<ImageGallery
ref={galleryRef}
items={images}
onSlide={(index) => console.log("Slid to", index)}
/>
);
}
For more examples, see example/App.jsx
items: (required) Array of objects. Available properties:
original - image source URLthumbnail - thumbnail source URLfullscreen - fullscreen image URL (defaults to original)originalHeight - image height (html5 attribute)originalWidth - image width (html5 attribute)loading - "lazy" or "eager" (HTML5 attribute)thumbnailHeight - image height (html5 attribute)thumbnailWidth - image width (html5 attribute)thumbnailLoading - "lazy" or "eager" (HTML5 attribute)originalClass - custom image classthumbnailClass - custom thumbnail classrenderItem - Function for custom rendering a specific slide (see renderItem below)renderThumbInner - Function for custom thumbnail renderer (see renderThumbInner below)originalAlt - image altthumbnailAlt - thumbnail image altoriginalTitle - image titlethumbnailTitle - thumbnail image titlethumbnailLabel - label for thumbnaildescription - description for imagesrcSet - image srcset (html5 attribute)sizes - image sizes (html5 attribute)bulletClass - extra class for the bullet of the iteminfinite: Boolean, default true - loop infinitelylazyLoad: Boolean, default falseshowNav: Boolean, default trueshowThumbnails: Boolean, default truethumbnailPosition: String, default bottom - options: top, right, bottom, leftshowFullscreenButton: Boolean, default trueuseBrowserFullscreen: Boolean, default true - if false, uses CSS-based fullscreenuseTranslate3D: Boolean, default true - if false, uses translate instead of translate3dshowPlayButton: Boolean, default trueisRTL: Boolean, default false - right-to-left modeshowBullets: Boolean, default falsemaxBullets: Number, default undefined - max bullets shown (minimum 3, active bullet stays centered)showIndex: Boolean, default falseautoPlay: Boolean, default falsedisableThumbnailScroll: Boolean, default false - disable thumbnail auto-scrolldisableKeyDown: Boolean, default false - disable keyboard navigationdisableSwipe: Boolean, default falsedisableThumbnailSwipe: Boolean, default falseonErrorImageURL: String, default undefined - fallback image URL for failed loadsindexSeparator: String, default ' / ', ignored if showIndex is falseslideDuration: Number, default 550 - slide transition duration (ms)swipingTransitionDuration: Number, default 0 - transition duration while swiping (ms)slideInterval: Number, default 3000slideOnThumbnailOver: Boolean, default falseslideVertically: Boolean, default false - slide vertically instead of horizontallyflickThreshold: Number, default 0.4 - swipe velocity threshold (lower = more sensitive)swipeThreshold: Number, default 30 - percentage of slide width needed to trigger navigationstopPropagation: Boolean, default false - call stopPropagation on swipe eventsstartIndex: Number, default 0onImageError: Function, callback(event) - overrides onErrorImageURLonThumbnailError: Function, callback(event) - overrides onErrorImageURLonThumbnailClick: Function, callback(event, index)onBulletClick: Function, callback(event, index)onImageLoad: Function, callback(event)onSlide: Function, callback(currentIndex)onBeforeSlide: Function, callback(nextIndex)onScreenChange: Function, callback(isFullscreen)onPause: Function, callback(currentIndex)onPlay: Function, callback(currentIndex)onClick: Function, callback(event)onTouchMove: Function, callback(event) on gallery slideonTouchEnd: Function, callback(event) on gallery slideonTouchStart: Function, callback(event) on gallery slideonMouseOver: Function, callback(event) on gallery slideonMouseLeave: Function, callback(event) on gallery slideadditionalClass: String, additional class for the root noderenderCustomControls: Function, render custom controls on the current sliderenderItem: Function, custom slide renderingrenderThumbInner: Function, custom thumbnail renderingrenderLeftNav: Function, custom left nav componentrenderRightNav: Function, custom right nav componentrenderTopNav: Function, custom top nav component (vertical mode)renderBottomNav: Function, custom bottom nav component (vertical mode)renderPlayPauseButton: Function, custom play/pause buttonrenderFullscreenButton: Function, custom fullscreen buttonuseWindowKeyDown: Boolean, default true - use window or element for key eventsThe following functions can be accessed using refs
play(): starts the slideshowpause(): pauses the slideshowtogglePlay(): toggles between play and pausefullScreen(): enters fullscreen modeexitFullScreen(): exits fullscreen modetoggleFullScreen(): toggles fullscreen modeslideToIndex(index): slides to a specific indexgetCurrentIndex(): returns the current indexPull requests should be focused on a single issue. If you're unsure whether a change is useful or involves a major modification, please open an issue first.
Requires Node.js >= 18.18
git clone https://github.com/xiaolin/react-image-gallery.git
cd react-image-gallery
npm install
npm start
Then open localhost:8001 in a browser.
MIT © Xiao Lin