OsirionPageLayout renders the shell of a page: a header, a main and a footer, stacked so the footer sits at
the bottom of the viewport on short pages. Use it in your MainLayout.razor.
Usage
@inherits LayoutComponentBase
@using Osirion.Blazor.Components
<OsirionPageLayout>
<Header>
<NavMenu />
</Header>
<Body>
@Body
</Body>
<Footer>
<OsirionFooter CompanyName="Example Ltd" />
</Footer>
</OsirionPageLayout>
The layout loads a small collocated script through BlazorJSComponents, so register its services in Program.cs:
builder.Services.AddJSComponents();
The Bootstrap example site in the repository uses the layout this way, with an
announcement bar above the menu in the Header slot:
<OsirionPageLayout StickyFooter EnableHeaderScrollBehavior>
<Header>
<OsirionAnnouncementBar Id="release-4-0">
New in 4.0: tabs, FAQ and feeds. <a href="/blog">Read more</a>
</OsirionAnnouncementBar>
<NavMenu />
</Header>
<Body>
@Body
</Body>
<Footer>
<OsirionFooter CompanyName="Example Ltd" />
</Footer>
</OsirionPageLayout>
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
Header |
RenderFragment? |
null |
Content of the header element; no header is rendered when it is null. |
Body |
RenderFragment? |
null |
Content of the main element. |
Footer |
RenderFragment? |
null |
Content of the footer element; no footer is rendered when it is null. |
StickyFooter |
bool |
true |
Keeps the footer at the bottom of the viewport when the content is short. |
EnableHeaderScrollBehavior |
bool |
true |
Makes the header sticky; it slides away while scrolling down and returns while scrolling up. |
MinHeightStrategy |
string |
"viewport" |
"viewport" sets min-height: 100vh; "content" sets min-height: 100%. |
ShowSkipLink |
bool |
true |
Renders a "skip to main content" link as the first focusable element. Available from 4.1. |
SkipLinkText |
string |
"Skip to main content" |
Text of the skip link; translate it for other languages. Available from 4.1. |
MainContentId |
string |
"osirion-main-content" |
id of the main element, which the skip link targets. Available from 4.1. |
Class and unmatched attributes go on the outer div.
Behavior
- Static SSR. The header, main and footer render on the server. The sticky footer is pure CSS (a flex column).
- Header on scroll. With
EnableHeaderScrollBehaviorthe header isposition: sticky; the script hides it while you scroll down past the first 100 pixels and shows it again when you scroll up or return to the top. When the visitor prefers reduced motion the script leaves the header in place. Without script the header simply stays sticky. - Skip link (4.0). The link stays off screen until it receives keyboard focus, then appears at the top left. Its
address is the current page plus
#andMainContentId, because a bare#idwould resolve against<base href="/">and lead to the home page. Themainelement hastabindex="-1", and the script moves focus to it after the jump, which Blazor's enhanced navigation would otherwise skip. - One footer landmark (4.0). Inside the
Footerslot, OsirionFooter renders adivinstead of its ownfooter, so the page keeps a single contentinfo landmark. In 4.0 it rendered a nestedfooter.
Styling
| Class | Element |
|---|---|
osirion-page-layout |
Outer div, plus osirion-sticky-footer-layout and osirion-min-height-viewport or osirion-min-height-content. |
osirion-page-header |
The header; osirion-page-header-scroll when the scroll behavior is on. |
osirion-page-main |
The main element. |
osirion-page-footer |
The footer. |
osirion-skip-link |
The skip link (4.0). |
The scrolling header has z-index: 1000. The skip link uses the page's own text and background colors, inverted,
and the theme's focus ring (--osirion-focus-ring-color, --osirion-focus-ring-width, --osirion-focus-ring-offset).
Related
Related Articles

