PageHeader Component
The <PageHeader> component is designed to render a consistent header for pages and/or sections within your application. It supports an optional icon or image, title, description and more.
Basic Usage
The component renders a header with a title and description.
- Basic
- With Image
- Profile
- With Icon
- With Actions
import { PageHeader } from "react-better-html";
function App() {
return (
<PageHeader title="Addresses" description="All available addresses listed bellow" />
);
}
import { PageHeader } from "react-better-html";
function App() {
return (
<PageHeader
imageUrl="https://picsum.photos/200/300"
title="Addresses"
description="All available addresses listed bellow"
/>
);
}
import { PageHeader } from "react-better-html";
function App() {
return (
<PageHeader
imageUrl="https://picsum.photos/200/300"
imageAzProfileImage
title="John Doe"
description="john@example.com"
/>
);
}
Renders the image with <Image.profileImage>.
import { PageHeader } from "react-better-html";
function App() {
return (
<PageHeader
icon="filter"
iconSize={24}
title="Filters"
titleAs="h2"
/>
);
}
import { Button, PageHeader } from "react-better-html";
function App() {
return (
<PageHeader
title="Addresses"
description="All available addresses listed bellow"
rightElement={<Button text="Add New" icon="XMark" />}
/>
);
}
Common Props
type PageHeaderProps = {
icon?: IconName;
iconColor?: string;
iconSize?: number;
image?: AssetName;
imageUrl?: string;
imageSize?: number;
imageWidth?: React.CSSProperties["width"];
imageHeight?: React.CSSProperties["height"];
imageAzProfileImage?: boolean;
imageObjectFit?: React.CSSProperties["objectFit"];
title?: string | React.ReactNode;
titleAs?: TextAs;
titleFontSize?: React.CSSProperties["fontSize"];
titleColor?: React.CSSProperties["color"];
titleRightElement?: React.ReactNode;
description?: string | React.ReactNode;
descriptionFontSize?: React.CSSProperties["fontSize"];
descriptionColor?: React.CSSProperties["color"];
imageGap?: React.CSSProperties["gap"];
titleGap?: React.CSSProperties["gap"];
textAlign?: React.CSSProperties["textAlign"];
rightElement?: React.ReactNode;
lightMode?: boolean;
width?: React.CSSProperties["width"];
flex?: React.CSSProperties["flex"];
} & Pick<ComponentMarginProps, "marginBottom">;
icon/iconColor/iconSize- an icon rendered before the title (size defaults to20)image/imageUrl- an asset name or a URL of an image to display in the headerimageSize- the size of the image in pixels (defaults to60)imageWidth/imageHeight/imageObjectFit- override the image size and fitimageAzProfileImage- renders the image as a circular profile imagetitle- the title text or a custom elementtitleAs- the HTML tag to use for the title (defaults toh1)titleFontSize/titleColor- the style of the titletitleRightElement- react element to render right after the title textdescription- the description text or a custom elementdescriptionFontSize/descriptionColor- the style of the descriptionimageGap- the space between the image/icon and the texts (defaults totheme.styles.space)titleGap- the space between the title and the description (defaults totheme.styles.gap / 2)textAlign- the text alignment for the title and descriptionrightElement- react element to display in the right end of the componentlightMode- if true, uses white text colorsmarginBottom- the space under the header (defaults totheme.styles.space * 2)
tip
The same header props are available on <Div.box> and <Foldable>.