Open In App

ReactJS Semantic UI Ref Addons

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 predefined CSS and JQuery to incorporate different frameworks.

In this article, we will learn how to use Ref Addons in ReactJS Semantic UI. Ref Addons is used to make both functional and class components. We can use innerRef property with useRef method



Property:

Syntax:



<Ref>Children content</Ref>

 

Creating React Application And Installing Module:

Project Structure: It will look like the following.

Example: this is the basic example that shows how to use Ref addons.




import React from "react";
import { Grid, Ref, Segment } from "semantic-ui-react";
   
function RefExampleRef() {
  const objectRef = React.useRef(null);
   
  return (
    <div id="gfg">
      <Grid>
        <Grid.Column width={6}>
          <Segment.Group>
            <Ref>
              <h1>Semantic UI Ref Element</h1>
            </Ref>
          </Segment.Group>
          <Segment.Group>
            <Ref>
              <Segment>A Ref Node </Segment>
            </Ref>
   
            <Ref innerRef={objectRef}>
              <Segment>
                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 
                predefined CSS and JQuery to 
                incorporate different frameworks.
              </Segment>
            </Ref>
          </Segment.Group>
        </Grid.Column>
      </Grid>
    </div>
  );
}
   
export default RefExampleRef;




#gfg {
    margin: 40px;
}

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

npm start

Output: 


Article Tags :