Skip to content
# Container ## Description The BitContainer component centers the content of a page in a column with a maximum width and side gutters: the block every site otherwise copies into its pages (a max-width, margin-inline: auto and a padding per breakpoint). It takes the whole width it is given up to MaxWidth (80rem by default, gutters included), centers itself in what is left, and pads its content with a gutter that grows from a phone to a desktop unless NoGutter removes it. ## Parameters | Name | Type | Default Value | Description | | :--- | :--- | :------------ | :---------- | | ChildContent | `RenderFragment?` | null | The content to be rendered inside the BitContainer. | | Element | `string?` | null | Gets or sets the custom html element used for the root node, "div" by default. A container that holds the main content of the page is more meaningful as a main, one that holds a region of it as a section or an article. Only the tag name changes, and with it the semantics reported to assistive technologies, so a landmark element given here is worth pairing with an AriaLabel that names it. | | MaxWidth | `string?` | null | Gets or sets the maximum width of the BitContainer, in which its content is then centered. Takes any CSS length (for example 1200px or 75rem), or none for a container that spans the whole width it is given and only keeps its gutters. The width includes the gutters. An explicit value wins over the --bit-Container-max-width variable; left unset, the container is 80rem (1280px, the large breakpoint) wide at most unless that variable says otherwise. | | NoGutter | `bool` | false | Removes the inline paddings (the gutters) of the BitContainer, so its content can span its full width. It wins over the --bit-Container-padding-inline variable; the block padding is not a gutter, so it is left alone. | | 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. | ## 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. | ## Enums ### 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. | ## CSS Variables Public CSS custom properties read off the component's root. Set one on `:root` to restyle every instance, on any ancestor to restyle the ones inside it, or on the `Style` of one instance to restyle it and every instance nested inside it, which inherits the value too - a parameter changes one alone, as does the real CSS property on its `Style` / `Styles` when that property does not inherit (`opacity`); an inherited one (`color`, `font-family`) reaches the nested instances that do not set it themselves. | Name | Default Value | Description | | :--- | :------------ | :---------- | | `--bit-Container-max-width` | 80rem | Maximum width of the container, gutters included. The MaxWidth parameter wins over it. It inherits, so a value set on a container also reaches the containers nested in it; MaxWidth is the way to size one container alone. | | `--bit-Container-padding-inline` | spacing(2), spacing(3) from sm, spacing(4) from md | The gutters on the two sides of the content. A value set here holds at every width (the steps are the default's alone), and NoGutter wins over it. | | `--bit-Container-padding-block` | 0 | Room above and below the content. | ## Examples \n**Basic**: ```razor
The content of the page
``` \n**MaxWidth**: ```razor
480px

40rem

none
``` \n**NoGutter**: ```razor
No gutter
``` \n**Full-width bands**: ```razor
A full-width hero
Its text lines up with the section below.
The section under the hero, in a container of the same width.
``` \n**Element**: ```razor
A section landmark
``` \n**Cascading parameters**: ```razor
Cascaded 480px

Its own 320px
``` ```csharp private readonly BitContainerParams[] containerParams = [ new() { MaxWidth = "480px" } ]; ``` \n**Style & Class**: ```razor
Variables on Style

Class
```