Skip to content
Related Articles

Related Articles

Improve Article

ReactJS Semantic UI Segment Element

  • Last Updated : 13 Jun, 2021
Geek Week

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 segment elements in ReactJS Semantic UI. The segment element is used to create a grouping of related content.

Properties:

  • Placeholder Segment: A segment can be used to reserve space for conditionally displayed content.
  • Raised: A segment may be formatted to raise above the page
  • Stacked: A segment can be formatted to show it contains multiple pages.
  • Piled: A segment can be formatted to look like a pile of pages.
  • Vertical Segment: A vertical segment formats content to be aligned as part of a vertical group.

States:

  • Disabled: disabled segment.
  • Loading: segment is loading.

 



Syntax:

<segment content='content' />

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.

 



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

npm start

Example 1: In this example, we will use a simple segment component to create a segment of content by using the Semantic UI Segment element.

App.js




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

Output: 

Example 2: In this example, we will use a segment component with loading state to show that the content of segment is being loaded by using Semantic UI Segment element. 

App.js




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

Output: 

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




My Personal Notes arrow_drop_up
Recommended Articles
Page :