On this page
Import
import { Page, PageHeader } from '@envsemble/envui';
Usage
Page holds the page's content as children, and its heading, a PageHeader, in header, at the top of the same column.
- Put it in a Scaffold's body, which is already the
mainlandmark: add none around a Page.
import { Button, Card, Page, PageHeader, Column, Text } from '@envsemble/envui';
import { IconAdd } from '@envsemble/envui/icons/Add';
const projects = [
{ name: 'Northwind launch', owner: 'Alex Morgan' },
{ name: 'Annual report', owner: 'Priya Shah' },
];
export default function WithHeader() {
return (
<Page
width="md"
header={
// Level 3 inside these docs; a page's own header keeps the default, 1.
<PageHeader
headingLevel={3}
title="Projects"
description="Everything your team is working on."
actions={<Button startIcon={<IconAdd />}>New project</Button>}
/>
}
>
<Column gap={3}>
{projects.map((project) => (
<Card key={project.name} title={project.name}>
<Text variant="body-sm">Owned by {project.owner}</Text>
</Card>
))}
</Column>
</Page>
);
}Width and gutter
widthissm, 40 rem,md, 60 rem,lg, 76 rem and the default, orfull.gutterpads the column's inline edges with the page gutter, 1 rem in a compact region and 1.5 rem from medium, by the window class of the region the page sits in, so a page in a narrow pane of a wide window keeps the compact gutter.gutter={false}leaves them to the content, such as a full-bleed table.
<Page width="sm" header={<PageHeader title="Settings" />}>
…
</Page>
<Page width="full" gutter={false}>
…
</Page>
Element and name
render sets the element, a div by default, such as render={<article />} for a document. name names the node for dev mode, as data-env-name.
The header
A PageHeader takes the page's title, which wraps, balanced across its lines, and is never cut short.
descriptiongoes under it, in the smaller muted text.breadcrumbsgo above it, usually Breadcrumbs withwrap={false}.startgoes before it, such as an Avatar, an icon or a back IconButton.metagoes beside it, such as Badges or a count.- The page's
actionsgo at the end of the title row, the primary action last. - The page's title and actions go here, not in the top bar, which belongs to the frame.
<PageHeader
title="Northwind launch"
description="Press kit, venue and invitations for the spring launch."
breadcrumbs={<Breadcrumbs wrap={false} items={trail} />}
meta={<Badge tone="success">On track</Badge>}
actions={
<>
<Button variant="secondary" startIcon={<IconShare />}>
Share
</Button>
<Button>New task</Button>
</>
}
/>
Heading level
The title is an h1 by default. Set headingLevel lower for a header inside a pane, a dialog or a section under another heading; it looks the same at every level.
Toolbar
toolbar adds a second row under the title for search, filters and view switches, laid out with <Row wrap justify="between">.
- A row that holds a text field is a Row, not a Toolbar, so the field keeps its arrow keys.
controlSizeismd, the default, orsmfor a dense page, such as one in a small window: it sizes the buttons and icon buttons inactionsandtoolbarthat set none.- Give fields in the toolbar the same
size.
<PageHeader
title="People"
controlSize="sm"
actions={<Button startIcon={<IconAdd />}>Invite</Button>}
toolbar={
<Row wrap align="center" justify="between" gap={3}>
<SearchField label="Search people" size="sm" />
<SegmentedControl
aria-label="View"
size="sm"
value={view}
onValueChange={setView}
items={views}
/>
</Row>
}
/>
Sticky
sticky keeps the header in view at the top of the area that scrolls, over the content under it: under a Scaffold's top bar where the document scrolls, or at the top of a Scaffold's body that scrolls.
- As a Page's header, what scrolls into view below it, such as a field taking focus, keeps clear of it.
- The header measures its height, which CSS reckons from its rows until script runs.
<Page
header={
<PageHeader
sticky
title="Annual report"
actions={<Button variant="secondary">Download</Button>}
/>
}
>
…
</Page>
Composition
The page, env-page, holds its header and its content, env-page-content, at its width.
- It never paints, and it is the
env-pagesize container for the content inside. data-widthcarries a width other thanlg, anddata-gutter="none"a page without the gutter.
The header is a div, no landmark, env-page-header, with the breadcrumbs, env-page-header-breadcrumbs, the start, env-page-header-start, the title, env-page-header-title, the meta, env-page-header-meta, the description, env-page-header-description, the actions, env-page-header-actions, and the toolbar, env-page-header-toolbar.
- It responds to its own width: below 37.5 rem the actions move under the title and wrap.
- Put more actions than fit in a Menu as the last one.
Accessibility
You provide
- The page's one
h1, usually its header's title, and aheadingLevelthat fits the headings around a header in a pane or a dialog. render={<article />}where the page is one, such as a document.- Names for icon-only actions and labels for the fields in the header's toolbar.
envUI provides
- A plain element without a role, so the page adds no landmark inside the Scaffold's
main. - The header as a
div, no landmark, with the title as a heading atheadingLevel. - The header's parts in the same order to read, to tab through and to see, at every width.
- With a sticky header, a scroll margin that keeps what takes focus clear of it.
Props
Page
The column a page's content sits in: invisible structure that never paints, centered, as wide as `width` at most, with the page gutter at its edges and the page's header at its top. Its gutters follow the window class of the region it sits in, such as a Scaffold's body or a pane, and it is the env-page container for the content inside. It adds no landmark; put it in a Scaffold's body, or the application's own main.
| Prop | Type | Description |
|---|---|---|
widthDefault 'lg' | 'sm''md''lg''full' | How wide the content may grow, a readable width: sm (40 rem) for a form or a settings page, md (60 rem) for a document or a detail page, lg (76 rem) for a dashboard or a list, full for content that uses the whole width, such as a board. The column is centered in the space it has. |
header | ReactNode | The page's heading, usually a PageHeader, at the top of the same column. |
gutterDefault true | boolean | Pads the column at its inline edges with the page gutter, which follows the window class of the region the page sits in: 1 rem in a compact one, 1.5 rem from medium. False leaves the edges to the content, such as a page that is one full-bleed table. |
name | string | A name for this node, such as "settings", which dev mode and the docs show; it renders as `data-env-name`. |
render | ReactElement | The element to render, for its meaning, such as render={<article />}; a div by default. The page's class and attributes merge into its props. |
children | ReactNode | The page's content, under its header. |
Also accepts the native props of <div>, such as ref, className and aria-* attributes.
PageHeader
The heading of a page: its title with an optional trail above it, a description, leading content, meta beside the title, actions at the end and a toolbar row under it, built from Row and Column. It responds to its own width, and can stick to the top of the area that scrolls.
| Prop | Type | Description |
|---|---|---|
titlerequired | ReactNode | The page's title. It wraps, balanced across its lines, and is never cut short. |
headingLevelDefault 1 | 123456 | The title's heading level: 1 for the page's own heading, a lower level for a header inside a pane or a section that sits under another heading. It looks the same at every level. |
description | ReactNode | A sentence under the title, in the smaller muted text, such as what the page is for. |
breadcrumbs | ReactNode | The trail to the page, usually Breadcrumbs with wrap={false}, above the title. |
start | ReactNode | Before the title: an Avatar, an icon or a back IconButton. |
meta | ReactNode | Beside the title, wrapping with it: Badges, such as a status, or a count. |
actions | ReactNode | The page's actions, at the end of the title row: its primary action last. Below 37.5 rem of the header's own width, a compact one, they move under the title and wrap. |
toolbar | ReactNode | A second row under the title: search, filters and view switches, laid out with `<Row wrap justify="between">`; see Toolbar's layouts. |
stickyDefault false | boolean | Keeps the header in view at the top of the area that scrolls, over the content that scrolls under it: under a Scaffold's top bar where the document scrolls, or at the top of a Scaffold's body that scrolls. As a Page's header, what scrolls into view below it, such as a field taking focus, keeps clear of it: the header measures its height, which CSS reckons from its rows until script runs. |
controlSizeDefault 'md' | 'sm''md' | The size of the buttons and icon buttons in `actions` and `toolbar` that set none: sm for a dense page, such as one in a small window, or md. Give fields in the toolbar the same `size`. |
Also accepts the native props of <div>, such as ref, className and aria-* attributes.
Part names
Each part's class and state attributes are public and versioned, for an application's CSS to style.
Page
env-page- The page: a readable width and the gutter; it never paints.
env-page-content- The page's content at its width.
data-gutternonedata-widthfull·lg·md·sm
PageHeader
env-page-header- The page header.
env-page-header-actions- The page's actions.
env-page-header-breadcrumbs- The breadcrumbs above the title.
env-page-header-description- The sentence under the title.
env-page-header-heading- The column with the title and the description.
env-page-header-meta- The facts beside the title.
env-page-header-row- The row with the title and the actions.
env-page-header-start- The content before the title, such as an avatar or a back button.
env-page-header-title- The title.
env-page-header-title-line- The line with the title and the meta.
env-page-header-toolbar- The toolbar under the title.
data-scrolled- Any value, or present
data-sticky- Present
Changelog
- 1.0.0
Page, with the widths
sm,md,lgandfull,header,gutter,nameandrender; invisible structure whose gutters follow the window class of the region it sits in, and theenv-pagecontainer. PageHeader, withtitle,headingLevel,description,breadcrumbs,start,meta,actions,toolbar,stickyandcontrolSize.- 1.0.0-prerelease.6
Colors under the pointer and while pressed change with
--env-motion-ease-enter, rather than easing in slowly, so hover and press show from the first frame.- 1.0.0-prerelease.3
PageHeader is documented on this page,
page, which its page's address opens.