Open In App

React Suite Container Navbar Layout

Last Updated : 26 Jul, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

React suite is a library of React components, sensible UI design, and a friendly development experience. It is supported in all major browsers. It provides pre-built components of React which can be used easily in any web application.

In this article, we’ll learn about React suite Container Navbar Layout. The container layout can define the main frame of the page using header, content, sidebar, and footer components. We can also add a navbar at the top of the webpage using the container navbar component.

Syntax:

<Container>
     <Header>Header</Header>
     <Navbar>
         ...
     </Navbar>
     <Content>Content</Content>
     <Footer>Footer</Footer>
</Container>

Creating React Application And Installing Module:

Step 1: Create a React application using the given command:

npm create-react-app projectname

Step 2: After creating your project, move to it using the given command:

cd projectname

Step 3: Now Install the rsuite node package using the given command:

npm install rsuite

Project Structure: Now your project structure should look like the following:

 

Example 1: Below example demonstrates the basic navbar layout.

Javascript




import { Container, Header, Content, Nav, Navbar } from "rsuite";
  
import "rsuite/dist/rsuite.min.css";
  
export default function App() {
    return (
        <div>
            <Container>
                <Header>
                    <Navbar appearance="inverse" 
                        style={{ backgroundColor: 'green' }}>
                        <Navbar.Brand>GeeksforGeeks</Navbar.Brand>
                        <Nav>
                            <Nav.Item>Home</Nav.Item>
                            <Nav.Item>About</Nav.Item>
                            <Nav.Item>Practice</Nav.Item>
                            <Nav.Menu title="Tutorials">
                                <Nav.Item>Data Structures</Nav.Item>
                                <Nav.Item>Algorithms</Nav.Item>
                                <Nav.Item>Web Development</Nav.Item>
                            </Nav.Menu>
                        </Nav>
                        <Nav pullRight>
                            <Nav.Item>Contact</Nav.Item>
                        </Nav>
                    </Navbar>
                </Header>
                <Content>
                    <h1 style={{ textAlign: 'center' }}>
                        Welcome to GeeksforGeeks
                    </h1>
                </Content>
            </Container>
        </div>
    );
}


Output: 

 

Example 2: Below example demonstrates the container navbar with icons layout.

Javascript




import { Container, Header, Content, Nav, Navbar } from "rsuite";
import Home from "@rsuite/icons/legacy/Home";
import Code from "@rsuite/icons/legacy/Code";
import Info from "@rsuite/icons/legacy/Info";
  
import "rsuite/dist/rsuite.min.css";
  
export default function App() {
    return (
        <div>
            <Container>
                <Header>
                    <Navbar appearance="inverse" 
                        style={{ backgroundColor: 'green' }}>
                        <Navbar.Brand>GeeksforGeeks</Navbar.Brand>
                        <Nav>
                            <Nav.Item icon={<Home />}>Home</Nav.Item>
                            <Nav.Item icon={<Info />}>About</Nav.Item>
                            <Nav.Item icon={<Code />}>Practice</Nav.Item>
                            <Nav.Menu title="Tutorials">
                                <Nav.Item>Data Structures</Nav.Item>
                                <Nav.Item>Algorithms</Nav.Item>
                                <Nav.Item>Web Development</Nav.Item>
                            </Nav.Menu>
                        </Nav>
                        <Nav pullRight>
                            <Nav.Item>Contact</Nav.Item>
                        </Nav>
                    </Navbar>
                </Header>
                <Content>
                    <h1 style={{ textAlign: 'center' }}>
                        Welcome to GeeksforGeeks
                    </h1>
                      
                    <p style={{ textAlign: 'center' }}>
                        This is a website for learning and practicing 
                        algorithms and data structures.
                    </p>
  
                </Content>
            </Container>
        </div>
    );
}


Output:

 

Reference: https://rsuitejs.com/components/container/#navbar-layout



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads