PageHolder Component
The <PageHolder> component is designed to provide a consistent layout for page content within your application. It applies padding, optional maximum width, and margin to center the content.
Basic Usage
The component wraps the main content of a page inside a <main> tag, ensuring the layout's semantics and look.
- Basic PageHolder
- No Max Width
import { Text, PageHolder } from "react-better-html";
function App() {
return (
<PageHolder>
<Text as="h1">Page Title</Text>
<Text>Page content here</Text>
// Rest of the page
</PageHolder>
);
}
import { PageHolder } from "react-better-html";
function App() {
return (
<PageHolder noMaxContentWidth>
<Text as="h1">Full Page Width Title</Text>
<Text>Full page width content here</Text>
// Rest of the page
</PageHolder>
);
}
You may need to the context of the app to not be constrained by a max-width so you can pass a noMaxContentWidth prop.
Common Props
noMaxContentWidth- Iftrue, the content will not be constrained by the maximum width defined in the<BetterHtmlProvider>configbackgroundColor/backgroundImage- the background of the holder- All padding props (
padding,paddingInline, ...). Defaults totheme.styles.space
Subcomponents
A number of components in the library have a subcomponent feature witch is like a preset of the same component that is frequently used.
PageHolder.center
This component centers its content vertically and horizontally on the screen inside a <Div.box>. It is perfect for login, register and other single-card pages.
- Basic
- With Side Component
- With Behind Component
import { PageHolder, PageHeader, Form, InputField } from "react-better-html";
function LoginPage() {
return (
<PageHolder.center>
<PageHeader title="Welcome back" titleAs="h2" />
<Form submitButtonText="Login" gap={10}>
<InputField.email />
<InputField.password />
</Form>
</PageHolder.center>
);
}
import { PageHolder, Image } from "react-better-html";
function LoginPage() {
return (
<PageHolder.center
sideComponent={<Image src="/login-cover.jpg" width="100%" height="100%" objectFit="cover" />}
sideComponentPosition="left"
>
...
</PageHolder.center>
);
}
The side component takes half of the screen and is hidden on small screens.
import { PageHolder, Div } from "react-better-html";
function LoginPage() {
return (
<PageHolder.center
behindComponent={<Div width="100%" height="100%" backgroundImage="linear-gradient(#6d466b, #412234)" />}
>
...
</PageHolder.center>
);
}
An element rendered behind the content box (backgrounds, animations, ...).
contentMaxWidth- the max width of the box (defaults to half ofapp.contentMaxWidth)contentInsideBox- set tofalseto render the content without the box stylesheight- the height of the boxpageBackgroundColor/pageBackgroundImage- the background of the whole pagesideComponent/sideComponentPosition- an element fixed on one half of the screen (rightby default)behindComponent- an element rendered behind the contentborder,borderRadius,boxShadowand all margin and padding props are applied to the box