Open In App

ReactJS UI Ant Design PageHeader Component

Last Updated : 07 Mar, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Ant Design Library has this component pre-built, and it is very easy to integrate as well. PageHeader Component is a header with common actions and design elements that are built-in. We can use the following approach in ReactJS to use the Ant Design PageHeader Component.

Syntax:

<PageHeader
  onBack={() => {
          // Action on click
        }}
        title=""
        subTitle=" "
        className=" "
/>

PageHeader Props:

  • avatar: It is the avatar that is just next to the title bar.
  • backIcon: It is the custom back icon.
  • breadcrumb: It is used to pass the breadcrumb configuration.  
  • breadcrumbRender: It is used to customize the content of breadcrumb area.
  • extra: It is the operating area that is placed just at the end of the line of title line
  • footer: It is the PageHeader footer, and it is used to render TabBar generally.
  • ghost: It is the PageHeader type, and it is used to change the background color.
  • subTitle: It is used to denote the custom text for the subtitle.
  • tags: It is used to denote the tag list which is just next to the title
  • title: It is used to denote the custom text for the title.
  • onBack: It is a callback that is triggered with the click of the Back icon.

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. folder name, move to it using the following command:

    cd foldername
  • Step 3: After creating the ReactJS application, Install the required module using the following command:

    npm install antd

Project Structure: It will look like the following.

Project Structure

Example: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.

App.js




import React from 'react'
import "antd/dist/antd.css";
import { PageHeader } from 'antd';
  
export default function App() {
  
  return (
    <div style={{ display: 'block', width: 700, padding: 30 }}>
      <h4>ReactJS Ant-Design PageHeader Component</h4>
      <PageHeader
        onBack={() => {
          console.log("Action you can perform on Click on Back button")
        }}
        title="GeeksforGeeks"
        subTitle="Greetings from GeeksforGeeks"
        className="site-page-header"
      />
    </div>
  );
}


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

npm start

Output: Now open your browser and go to http://localhost:3000/, you will see the following output:


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

Similar Reads