Thursday, November 28, 2024
Google search engine
HomeLanguagesReactJS Semantic UI Loader Element

ReactJS Semantic UI Loader Element

Semantic UI is a modern framework used in developing seamless designs for the website, It gives the user a lightweight experience with its components. It uses the predefined CSS, JQuery language to incorporate in different frameworks.

In this article we will know how to use the Loader element in ReactJS Semantic UI. Loader element is used to alert a user to wait for an activity to complete

Properties:

  • Text Loader: A loader containing text.

States:

  • Indeterminate: unsure that how long time will take to open a task.
  • Active: active loader.
  • Disabled: disabled loader.

 

Syntax:

<loader />

Creating React Application And Installing Module:

  • Step 1: Create a React application using the following command.

    npx create-react-app foldername
  • Step 2: After creating your project folder i.e. foldername, move to it using the following command.

    cd foldername
  • Step 3: Install semantic UI in your given directory.

     npm install semantic-ui-react semantic-ui-css

Project Structure: It will look like the following.

 

Example 1: In this example, we will use a loader, dimmer and segment component with props of dimmer as active which will alert the user to wait for the activity to complete by using ReactJS Semantic UI Loader element.

App.js




import React from 'react'
import {Loader, Dimmer, Segment} from 'semantic-ui-react'
  
const styleLink = document.createElement("link");
styleLink.rel = "stylesheet";
styleLink.href = 
document.head.appendChild(styleLink);
  
const Btt = () =>( 
<div>
    <br/>
<Segment>
    <Dimmer active>
      <Loader />
    </Dimmer>
</Segment>
</div>
)
  
  
export default Btt    


Step to Run Application: Run the application  from the root directory of the project, using the following command.

npm start

Output: 

Example 2: In this example, we will use a loader, dimmer and segment component with props of dimmer as active and the state of the segment will be loading to load the text by using ReactJS Semantic UI Loader element

App.js




import React from 'react'
import {Loader, Dimmer, Segment} from 'semantic-ui-react'
  
const styleLink = document.createElement("link");
styleLink.rel = "stylesheet";
styleLink.href = 
document.head.appendChild(styleLink);
  
const Btt = () =>( 
<div>
    <br/>
    <Dimmer active>
      <Loader content='loading'/>
    </Dimmer>
</div>
)
  
  
export default Btt    


Step to Run Application: Run the application  from the root directory of the project, using the following command.

npm start

Output: 

Reference: https://react.semantic-ui.com/elements/loader

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

RELATED ARTICLES

Most Popular

Recent Comments