Skip to content

WebNinjaDeveloper.com

Programming Tutorials




Menu
  • Home
  • Youtube Channel
  • Official Blog
  • Nearby Places Finder
  • Direction Route Finder
  • Distance & Time Calculator
Menu

React.js react-fullscreen-carousel Example to Display Multiple Images in Full Screen Carousel in Browser Using Javascript

Posted on February 19, 2023

 

 

Welcome folks today in this blog post we will be using the react-fullscreen-carousel library to display multiple images in carousel in browser using javascript. All the full source code of the application is shown below.

 

 

Get Started

 

 

In order to get started you need to make a new react.js app using the below command as shown below

 

 

npx create-react-app sampleapp

 

 

cd sampleapp

 

 

And after that you need to install the below library using the below command as shown below

 

 

npm i react-fullscreen-carousel

 

 

And after that you will see the below directory structure of the react.js app as shown below

 

 

 

 

 

Displaying Multiple Images in Carousel

 

 

Now we can modify the App.js file and copy paste the following code

 

 

App.js

 

 

JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import React from 'react';
import { ReactFullscreenCarousel } from 'react-fullscreen-carousel';
 
const data = [
    { img: "https://picsum.photos/400", alt: "image" },
    { img: "https://picsum.photos/500", alt: "image" },
    { img: "https://picsum.photos/600", alt: "image" },
    { img: "https://picsum.photos/700", alt: "image" },
    { img: "https://picsum.photos/650", alt: "image" },
    { img: "https://picsum.photos/750", alt: "image" },
];
 
export default function App(){
 
    const [open, setOpen] = React.useState(false);
 
    return (
        <main>
            {open ?
                <ReactFullscreenCarousel slides={data} handleClose={() => setOpen(false)} startSlideIndex={0} />
                : null
            }
            <button onClick={() => setOpen(true)}>Open images</button>
        </main>
    );
};

 

 

As you can see we are importing the react-fullscreen-carousel library at the top and then we have declared an array of images from the url and then we are displaying the react full screen carousel and here we are having the previous and next buttons and then we have the button to open the images inside the carousel.

 

 

 

Recent Posts

  • Angular 14/15 JWT Login & Registration Auth System in Node.js & Express Using MongoDB in Browser
  • Build a JWT Login & Registration Auth System in Node.js & Express Using MongoDB in Browser
  • React-Admin Example to Create CRUD REST API Using JSON-Server Library in Browser Using Javascript
  • Javascript Papaparse Example to Parse CSV Files and Export to JSON File and Download it as Attachment
  • Javascript Select2.js Example to Display Single & Multi-Select Dropdown & Fetch Remote Data Using Ajax in Dropdown
  • Angular
  • Bunjs
  • C#
  • Deno
  • django
  • Electronjs
  • java
  • javascript
  • Koajs
  • kotlin
  • Laravel
  • meteorjs
  • Nestjs
  • Nextjs
  • Nodejs
  • PHP
  • Python
  • React
  • ReactNative
  • Svelte
  • Tutorials
  • Vuejs




©2023 WebNinjaDeveloper.com | Design: Newspaperly WordPress Theme