Layouts
Header
BitHeader is the bar at the top of a site or an application (an app bar): a semantic header element - the banner landmark - holding a brand, navigation and actions in one line, with an optional second row for tabs. It can be pinned to the top, hide on scroll down, elevate once scrolled, slide away on demand, and carries a skip link and scroll padding for keyboard users.
Usage
Every example is live. Open its code to see exactly what produced the component running underneath.
Basic
Variant
Border & elevation
Alignment
Layout
Extension
Position
Reveal
Elevate on scroll
My Awesome Application
Scroll target
Hidden
Translucent
Accessibility
Usage
Cascading parameters
Color
Size
Style & Class
RTL
CSS variables
The public custom properties this component reads off its root, for what no parameter covers.
Every variable is read with a fallback and never declared by the component, so it inherits like any other custom property:
set one on :root (or in a [bit-theme] block) to restyle every instance, on any ancestor to restyle the ones inside it,
or on the Style of one instance to restyle it - and any instance nested inside it, which inherits the value too; a parameter changes one alone,
as does the real CSS property on the instance's Style / Styles when that property does not inherit (opacity: 1 keeps
one disabled instance undimmed without undimming a disabled one inside it), while an inherited one such as color or
font-family also reaches the nested instances that do not set it themselves. Leave a variable unset and the component
falls back to the theme token beside it.
BitHeader CSS variables
| Name | Default value | Description |
|---|---|---|
| --bit-Header-background | --bit-clr-bg-pri | Fill of the Fill variant. The Color parameter wins over it. The Fill variant, the only one reading it, reads --bit-Header-fill-background ahead of it. |
| --bit-Header-fill-background | --bit-Header-background | Fill of a Fill header alone, read ahead of --bit-Header-background, like every variable a variant reads. The Color parameter wins over it. |
| --bit-Header-color | --bit-clr-fg-pri | Color of the content. The Color parameter wins over it. Shared by the three variants: --bit-Header-fill-color, --bit-Header-outline-color and --bit-Header-text-color are read ahead of it. |
| --bit-Header-fill-color | --bit-Header-color | Color of the content of a Fill header alone, read ahead of --bit-Header-color so a theme can set this variant apart from the other two. The Color parameter wins over it. |
| --bit-Header-outline-color | --bit-Header-color | Color of the content of an Outline header alone, read ahead of --bit-Header-color so a theme can set this variant apart from the other two. The Color parameter wins over it. |
| --bit-Header-text-color | --bit-Header-color | Color of the content of a Text header alone, read ahead of --bit-Header-color so a theme can set this variant apart from the other two. The Color parameter wins over it. |
| --bit-Header-border-color | --bit-clr-brd-pri | Border of the Outline variant, and the divider of a Bordered header. The Color parameter wins over it. Shared by the three variants: --bit-Header-fill-border-color, --bit-Header-outline-border-color and --bit-Header-text-border-color are read ahead of it. |
| --bit-Header-fill-border-color | --bit-Header-border-color | Divider of a Bordered Fill header alone, read ahead of --bit-Header-border-color so a theme can set this variant apart from the other two. The Color parameter wins over it. |
| --bit-Header-outline-border-color | --bit-Header-border-color | Border of an Outline header alone, read ahead of --bit-Header-border-color so a theme can set this variant apart from the other two. The Color parameter wins over it. |
| --bit-Header-text-border-color | --bit-Header-border-color | Divider of a Bordered Text header alone, read ahead of --bit-Header-border-color so a theme can set this variant apart from the other two. The Color parameter wins over it. |
| --bit-Header-border-width | --bit-shp-brd-width | Thickness of that border and divider. Shared by the three variants: --bit-Header-fill-border-width, --bit-Header-outline-border-width and --bit-Header-text-border-width are read ahead of it. |
| --bit-Header-fill-border-width | --bit-Header-border-width | Thickness of the divider of a Bordered Fill header alone, read ahead of --bit-Header-border-width so a theme can set this variant apart from the other two. |
| --bit-Header-outline-border-width | --bit-Header-border-width | Thickness of the border of an Outline header alone, read ahead of --bit-Header-border-width so a theme can set this variant apart from the other two. |
| --bit-Header-text-border-width | --bit-Header-border-width | Thickness of the divider of a Bordered Text header alone, read ahead of --bit-Header-border-width so a theme can set this variant apart from the other two. |
| --bit-Header-border-radius | 0 | Corners of the surface, for a floating header inset from the edges of its page or card. |
| --bit-Header-padding-block | spacing(1) | Room above and below the main row. The Size parameter wins over it, and NoGutter over both. |
| --bit-Header-padding-inline | spacing(3) | Room on the two sides of both rows. The Size parameter wins over it, and NoGutter over both. |
| --bit-Header-min-height | 0 | Minimum height of the main row (for example the 64px of a Material top app bar). |
| --bit-Header-gap | 0 | Space between the children of the main row. The Gap parameter outranks it. |
| --bit-Header-max-width | none | Maximum width of the content of both rows. The MaxWidth parameter outranks it. |
| --bit-Header-shadow | --bit-shd-appbar-top | Shadow of an Elevated header, or of an ElevateOnScroll one once scrolled. |
| --bit-Header-z-index | --bit-zin-base | Stacking order of a Fixed, Sticky or Absolute header. |
| --bit-Header-backdrop-blur | 12px | Blur of what passes behind a Translucent header. The Fill variant, the only one reading it, reads --bit-Header-fill-backdrop-blur ahead of it. |
| --bit-Header-fill-backdrop-blur | --bit-Header-backdrop-blur | Blur of what passes behind a Translucent Fill header alone, read ahead of --bit-Header-backdrop-blur, like every variable a variant reads. |
| --bit-Header-translucent-opacity | 72% | How much of its fill a Translucent header keeps. The Fill variant, the only one reading it, reads --bit-Header-fill-translucent-opacity ahead of it. |
| --bit-Header-fill-translucent-opacity | --bit-Header-translucent-opacity | Share of its fill a Translucent Fill header alone keeps, read ahead of --bit-Header-translucent-opacity, like every variable a variant reads. |
| --bit-Header-disabled-color | --bit-clr-fg-dis | Content color of a disabled header, and the border of a disabled Outline one. The Color parameter wins over it. Shared by the three variants: --bit-Header-fill-disabled-color, --bit-Header-outline-disabled-color and --bit-Header-text-disabled-color are read ahead of it. |
| --bit-Header-fill-disabled-color | --bit-Header-disabled-color | Content color of a disabled Fill header alone, read ahead of --bit-Header-disabled-color so a theme can set this variant apart from the other two. The Color parameter wins over it. |
| --bit-Header-outline-disabled-color | --bit-Header-disabled-color | Content and border color of a disabled Outline header alone, read ahead of --bit-Header-disabled-color so a theme can set this variant apart from the other two. The Color parameter wins over it. |
| --bit-Header-text-disabled-color | --bit-Header-disabled-color | Content color of a disabled Text header alone, read ahead of --bit-Header-disabled-color so a theme can set this variant apart from the other two. The Color parameter wins over it. |
| --bit-Header-disabled-background | --bit-clr-bg-pri | Fill of a disabled Fill header. The Color parameter wins over it. The Fill variant, the only one reading it, reads --bit-Header-fill-disabled-background ahead of it. |
| --bit-Header-fill-disabled-background | --bit-Header-disabled-background | Fill of a disabled Fill header alone, read ahead of --bit-Header-disabled-background, like every variable a variant reads. The Color parameter wins over it. |
| --bit-Header-skip-link-color | --bit-clr-pri-text | Text color of the focused skip link. |
| --bit-Header-skip-link-background | --bit-clr-pri | Fill of the focused skip link. |
API
Every parameter, public member, sub-class and enum this component exposes.
BitHeader parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| Absolute | bool | false | Renders the header with an absolute position at the top of its nearest positioned ancestor. Fixed takes precedence over it, and it takes precedence over Sticky. |
| Alignment | BitAlignment? | null | Gets or sets the horizontal distribution of the content of the BitHeader (the CSS justify-content of the container). Baseline and Stretch act on the cross axis (the vertical alignment) instead. |
| Bordered | bool | false | Renders a divider line on the bottom edge of the BitHeader to separate it from the content below. |
| ChildContent | RenderFragment? | null | Gets or sets the content to be rendered inside the BitHeader. |
| Classes | BitHeaderClassStyles? | null | Custom CSS classes for different parts of the BitHeader. |
| Color | BitColor? | null | The general color of the BitHeader. It is applied through the Variant: as the background color in the Fill variant, and as the text and border color in the Outline and Text variants. An explicit value wins over the --bit-Header-* color variables; left unset, the header keeps the primary background and foreground colors of the theme unless they say otherwise. |
| ElevateOffset | int? | null | Gets or sets how far (in pixels) the scroll has to travel from the top before an ElevateOnScroll header lifts itself off the content. |
| ElevateOnScroll | bool | false | Keeps the BitHeader flat while the scrolling area sits at its top and lets it cast its shadow only once the content has been scrolled underneath it. It only has an effect on a Fixed or Sticky header, and Elevated takes precedence over it. |
| Elevated | bool | false | Renders the BitHeader with a shadow cast downwards, to lift it above the content it overlaps. |
| ExtensionContent | RenderFragment? | null | Gets or sets the content of a second row rendered under the main row of the BitHeader, such as a row of tabs, a search box or a breadcrumb. It shares the surface and the scroll behaviors of the header, takes the same inline gutter and MaxWidth as the main row, and has no block padding of its own. |
| Fixed | bool | false | Renders the header with a fixed position at the top of the page. It takes precedence over Absolute and Sticky when more than one of them is set. |
| Gap | string? | null | Gets or sets the space between the children of the BitHeader (the CSS gap of the container). It takes any CSS length or the two value form of the gap shorthand. |
| Height | int? | null | Gets or sets the height of the BitHeader (in pixels). The height includes the paddings and the border of the header. It is the exact height of a header with no ExtensionContent, and a minimum height of one with an ExtensionContent row, so the two rows together can grow the header past it rather than being clipped. A header that really sits at the top of the screen (Fixed, or Sticky without an Absolute outranking it) adds the top safe area inset of the device on top of it. |
| Hidden | bool | false | Slides the BitHeader out of the view, and brings it back when it is turned off again. A hidden header is also marked inert, so nothing inside it can be clicked or reached with the keyboard while it is out of the view. |
| MaxWidth | string? | null | Gets or sets the maximum width of the content of the BitHeader, which is then centered in the header. The header itself keeps spanning the full width, so its background, its border and its shadow still run edge to edge. |
| NoGutter | bool | false | Removes the default paddings around the content of the BitHeader, so it can span the full width of the header. |
| OnRevealChanged | EventCallback<bool> | Callback for when the reveal state of the header changes. The provided value is true when the header is revealed. Only invoked while Reveal is enabled. | |
| OnScrolledChanged | EventCallback<bool> | Callback for when the scrolled state of the header changes. The provided value is true once the scrolling area has travelled past the ElevateOffset. Only invoked while ElevateOnScroll is enabled. | |
| Reveal | bool | false | Slides the header out of the view while the page is scrolled down and brings it back while the page is scrolled up. It comes back when anything inside it takes the focus, and stays while it holds the keyboard focus. It only has an effect on a Fixed or Sticky header, since the others have nothing to slide over. |
| RevealOffset | int? | null | Gets or sets how far (in pixels) the scroll has to travel from the top before a Reveal header starts hiding itself. The header stays revealed while the scroll is still within this offset. |
| ScrollPadding | bool | false | Reserves the height of the BitHeader at the top of the scrolling area, so nothing scrolled to - the target of an anchor, a control that has just taken the focus, a call to scrollIntoView - lands underneath a pinned header (WCAG 2.4.11). It only has an effect on a Fixed or Sticky header. |
| ScrollTarget | string? | null | Gets or sets the CSS selector of the element whose scrolling drives the BitHeader. By default the header finds its own scrolling area by walking up from itself, and a selector that matches nothing falls back to that walk. |
| Size | BitSize? | null | The size of the BitHeader, which determines the paddings around its content. An explicit value wins over the --bit-Header-padding-* variables; left unset, the header is medium unless they say otherwise. |
| SkipLinkHref | string? | null | Gets or sets the target of the skip link of the BitHeader, which is what makes it render at all. It is rendered as the very first focusable element of the header and stays out of sight until it is focused. |
| SkipLinkText | string? | null | Gets or sets the text of the skip link of the BitHeader. It defaults to "Skip to main content" and is only rendered when a SkipLinkHref is provided. |
| Sticky | bool | false | Renders the header with a sticky position at the top of the viewport. Unlike Fixed, it keeps the room it occupies in the layout, so nothing has to be reserved for it, and it only covers the content once that content scrolls up to it. |
| Styles | BitHeaderClassStyles? | null | Custom CSS styles for different parts of the BitHeader. |
| Translucent | bool | false | Softens the background of the BitHeader and blurs what passes behind it, for the frosted glass look of a header pinned over scrolling content. Only the Fill variant has a background to soften. |
| Variant | BitVariant? | null | The visual variant of the BitHeader. |
| VerticalAlign | BitAlignment? | null | Gets or sets the vertical alignment of the content of the BitHeader (the CSS align-items of the container). Only Start, End, Center, Baseline and Stretch align a line on the cross axis, so the three space distributions are ignored here. |
| Wrap | bool | false | Lets the content of the BitHeader wrap onto more than one line instead of being squeezed into a single one. The lines are packed by VerticalAlign and separated by the row part of Gap. |
BitHeader public members
| Name | Type | Default value | Description |
|---|---|---|---|
| IsRevealed | bool | true | Gets a value indicating whether the header is currently revealed. It reports the scroll driven reveal state alone, so it is always true unless Reveal is enabled, and stays true for a header slid out of the view with Hidden. |
| IsScrolled | bool | false | Gets a value indicating whether the scrolling area of the header has travelled past the ElevateOffset. It is always false unless ElevateOnScroll is enabled. |
BitComponentBase parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| AriaLabel | string? | null | Gets or sets the accessible label for the component, used by assistive technologies. |
| Class | string? | null | Gets or sets the CSS class name(s) to apply to the rendered element. |
| Dir | BitDir? | null | Gets or sets the text directionality for the component's content. |
| Disabled | bool | false | Gets or sets a value indicating whether the component is disabled and cannot respond to user interaction. |
| ForceAnimation | bool | false | Gets or sets a value indicating whether the component's animations play at their full duration even when reduced motion is requested. |
| HtmlAttributes | Dictionary<string, object> | new Dictionary<string, object>() | Captures additional HTML attributes to be applied to the rendered element, in addition to the component's parameters. An attribute written on the component wins over an entry of the same name. |
| Id | string? | null | Gets or sets the unique identifier for the component's root element. |
| Style | string? | null | Gets or sets the CSS style string to apply to the rendered element. |
| TabIndex | string? | null | Gets or sets the tab order index for the component when navigating with the keyboard. |
| Visibility | BitVisibility | BitVisibility.Visible | Gets or sets the visibility state (visible, hidden, or collapsed) of the component. |
BitComponentBase public members
| Name | Type | Default value | Description |
|---|---|---|---|
| UniqueId | Guid | Guid.NewGuid() | Gets the readonly unique identifier for the component's root element, assigned when the component instance is constructed. |
| RootElement | ElementReference | Gets the reference to the root HTML element associated with this component. |
BitHeaderClassStyles properties
| Name | Type | Default value | Description |
|---|---|---|---|
| Root | string? | null | Custom CSS classes/styles for the root element of the BitHeader. |
| Container | string? | null | Custom CSS classes/styles for the container element of the BitHeader that wraps its content. |
| Extension | string? | null | Custom CSS classes/styles for the second row of the BitHeader, which is only rendered when an ExtensionContent is provided. |
| SkipLink | string? | null | Custom CSS classes/styles for the skip link of the BitHeader, which is only rendered when a SkipLinkHref is provided. |
BitAlignment enum
| Name | Value | Description |
|---|---|---|
| Start | 0 | Packs the content at the start of the line, or at the top of the header. |
| End | 1 | Packs the content at the end of the line, or at the bottom of the header. |
| Center | 2 | Packs the content at the center of the line, or in the middle of the header. |
| SpaceBetween | 3 | Distributes the free space between the items, with no space at the two edges. Ignored by VerticalAlign. |
| SpaceAround | 4 | Distributes the free space around the items, so the edges get half of what sits between the items. Ignored by VerticalAlign. |
| SpaceEvenly | 5 | Distributes the free space evenly between the items and at the two edges. Ignored by VerticalAlign. |
| Baseline | 6 | Aligns the content on its baseline (the cross axis of the header). |
| Stretch | 7 | Stretches the content to the full height of the header (the cross axis). |
BitColor enum
| Name | Value | Description |
|---|---|---|
| Primary | 0 | Primary general color. |
| Secondary | 1 | Secondary general color. |
| Tertiary | 2 | Tertiary general color. |
| Info | 3 | Info general color. |
| Success | 4 | Success general color. |
| Warning | 5 | Warning general color. |
| SevereWarning | 6 | SevereWarning general color. |
| Error | 7 | Error general color. |
| PrimaryBackground | 8 | Primary background color. |
| SecondaryBackground | 9 | Secondary background color. |
| TertiaryBackground | 10 | Tertiary background color. |
| PrimaryForeground | 11 | Primary foreground color. |
| SecondaryForeground | 12 | Secondary foreground color. |
| TertiaryForeground | 13 | Tertiary foreground color. |
| PrimaryBorder | 14 | Primary border color. |
| SecondaryBorder | 15 | Secondary border color. |
| TertiaryBorder | 16 | Tertiary border color. |
BitSize enum
| Name | Value | Description |
|---|---|---|
| Small | 0 | The small size. |
| Medium | 1 | The medium size. |
| Large | 2 | The large size. |
BitVariant enum
| Name | Value | Description |
|---|---|---|
| Fill | 0 | Fill styled variant. |
| Outline | 1 | Outline styled variant. |
| Text | 2 | Text styled variant. |
BitVisibility enum
| Name | Value | Description |
|---|---|---|
| Visible | 0 | The content of the component is visible. |
| Hidden | 1 | The content of the component is hidden, but the space it takes on the page remains (visibility:hidden). |
| Collapsed | 2 | The component is hidden (display:none). |
BitDir enum
| Name | Value | Description |
|---|---|---|
| Ltr | 0 | Ltr (left to right) is to be used for languages that are written from the left to the right (like English). |
| Rtl | 1 | Rtl (right to left) is to be used for languages that are written from the right to the left (like Arabic). |
| Auto | 2 | Auto lets the user agent decide. It uses a basic algorithm as it parses the characters inside the element until it finds a character with a strong directionality, then applies that directionality to the whole element. |
Feedback
Found a mistake, a gap, or something that could be clearer? Every page and every component is one click from its source.