Layouts
Grid
The BitGrid component divides the width it is given into equal columns and lays its BitGridItem children out over them, wrapping onto a new row whenever the next item no longer fits. The column count, the spacing and each item's span, offset and order all take a value per breakpoint, mobile first, and a span of no columns hides the item. Items can leave the columns behind entirely - as wide as their own content, sharing whatever the row has left, or fitted to a minimum width - and the breakpoints follow the window, or the width of the grid itself when it is asked to be a container.
Usage
Every example is live. Open its code to see exactly what produced the component running underneath.
Basic
Column span
Auto & Grow
Offset
Order
Alignment
Spacing
Breakpoints
Hiding
Fluid columns
Container queries
Wrapping & direction
Nesting
Element
- Apple
- Banana
- Cherry
- Date
- Elderberry
- Fig
- Grape
- Honeydew
Layout patterns
Style & Class
RTL
API
Every parameter, public member, sub-class and enum this component exposes.
BitGrid parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| AlignContent | BitAlignment? | null | Defines how the rows of a wrapping grid share out the height left over (the CSS align-content). It only shows up in a grid that wrapped onto more than one row and is taller than those rows needed, and it is not part of the Alignment shorthand. |
| Alignment | BitAlignment? | null | Gets or sets the alignment of the children of the grid on both axes at once. HorizontalAlign and VerticalAlign each take precedence over it on their own axis. |
| ChildContent | RenderFragment? | null | The content of the Grid. |
| Columns | int | 12 | Defines the number of columns the width of the grid is divided into. It is the count of every breakpoint that is not overridden, and values below 1 are treated as 1. |
| ColumnsXs | int? | null | Number of columns in the extra small breakpoint (from 0px). The value keeps applying to every wider breakpoint until another one replaces it. |
| ColumnsSm | int? | null | Number of columns in the small breakpoint (from 600px). The value keeps applying to every wider breakpoint until another one replaces it. |
| ColumnsMd | int? | null | Number of columns in the medium breakpoint (from 960px). The value keeps applying to every wider breakpoint until another one replaces it. |
| ColumnsLg | int? | null | Number of columns in the large breakpoint (from 1280px). The value keeps applying to every wider breakpoint until another one replaces it. |
| ColumnsXl | int? | null | Number of columns in the extra large breakpoint (from 1920px). The value keeps applying to every wider breakpoint until another one replaces it. |
| ColumnsXxl | int? | null | Number of columns in the extra extra large breakpoint (from 2560px). |
| Container | bool | false | Measures the breakpoints of the grid against its own width instead of the width of the viewport, by turning the grid into a CSS query container. The breakpoints keep their usual widths, so a grid in a 700px panel lays itself out the way the same grid lays itself out in a 700px window. |
| Element | string? | null | The custom html element used for the root node. The default is "div". |
| Grow | bool | false | Lets every child of the grid grow into whatever width its row did not use, which is what fills out the last, short row of a grid of otherwise equal items. The items that are sized to their own content are left alone. |
| HorizontalAlign | BitAlignment? | null | Defines the horizontal distribution of the children of the grid (the CSS justify-content). Baseline and Stretch distribute nothing, so those two act on the vertical axis instead. |
| HorizontalSpacing | string? | null | Defines the horizontal spacing between the children of the grid. It is taken out of the width of the row before the columns divide it up. Falls back to Spacing. |
| HorizontalSpacingXs | string? | null | Defines the horizontal spacing between the children of the grid from the extra small breakpoint (from 0px) upwards. The value keeps applying to every wider breakpoint until another one replaces it, and it takes precedence over SpacingXs. |
| HorizontalSpacingSm | string? | null | Defines the horizontal spacing between the children of the grid from the small breakpoint (from 600px) upwards. The value keeps applying to every wider breakpoint until another one replaces it, and it takes precedence over SpacingSm. |
| HorizontalSpacingMd | string? | null | Defines the horizontal spacing between the children of the grid from the medium breakpoint (from 960px) upwards. The value keeps applying to every wider breakpoint until another one replaces it, and it takes precedence over SpacingMd. |
| HorizontalSpacingLg | string? | null | Defines the horizontal spacing between the children of the grid from the large breakpoint (from 1280px) upwards. The value keeps applying to every wider breakpoint until another one replaces it, and it takes precedence over SpacingLg. |
| HorizontalSpacingXl | string? | null | Defines the horizontal spacing between the children of the grid from the extra large breakpoint (from 1920px) upwards. The value keeps applying to every wider breakpoint until another one replaces it, and it takes precedence over SpacingXl. |
| HorizontalSpacingXxl | string? | null | Defines the horizontal spacing between the children of the grid from the extra extra large breakpoint (from 2560px) upwards, and it takes precedence over SpacingXxl. |
| MinItemWidth | string? | null | Sizes the children of the grid to a width they may not go below instead of to a number of columns, and fits as many of them on a row as that width allows. Takes any CSS length, and a bare number is read as pixels. The items of a row share it equally, the last row included. The column tracks are left behind while it is set, except for the items that state Auto or Grow for themselves and except for the offsets, which are still counted in columns. |
| NoWrap | bool | false | Keeps the children of the grid on a single row, shrinking them to fit instead of letting them wrap onto more rows. |
| Reversed | bool | false | Renders the children of the grid in the opposite direction. Only the painted order is reversed; the reading and tab order stay as written. |
| Spacing | string | 4px | Defines the spacing between the children of the grid on both axes. HorizontalSpacing and VerticalSpacing each replace it on their own axis, and it is the spacing of every breakpoint that is not overridden. |
| SpacingXs | string? | null | Defines the spacing between the children of the grid on both axes from the extra small breakpoint (from 0px) upwards. The value keeps applying to every wider breakpoint until another one replaces it. |
| SpacingSm | string? | null | Defines the spacing between the children of the grid on both axes from the small breakpoint (from 600px) upwards. The value keeps applying to every wider breakpoint until another one replaces it. |
| SpacingMd | string? | null | Defines the spacing between the children of the grid on both axes from the medium breakpoint (from 960px) upwards. The value keeps applying to every wider breakpoint until another one replaces it. |
| SpacingLg | string? | null | Defines the spacing between the children of the grid on both axes from the large breakpoint (from 1280px) upwards. The value keeps applying to every wider breakpoint until another one replaces it. |
| SpacingXl | string? | null | Defines the spacing between the children of the grid on both axes from the extra large breakpoint (from 1920px) upwards. The value keeps applying to every wider breakpoint until another one replaces it. |
| SpacingXxl | string? | null | Defines the spacing between the children of the grid on both axes from the extra extra large breakpoint (from 2560px) upwards. |
| Span | int | 1 | Defines the number of columns the children of the grid fill by default, used by every item that does not set a ColumnSpan of its own. |
| VerticalAlign | BitAlignment? | null | Defines the vertical alignment of the children of the grid within a row (the CSS align-items). The three space distributions have no meaning on this axis and are ignored. |
| VerticalSpacing | string? | null | Defines the vertical spacing between the rows of the grid. Unlike HorizontalSpacing it has no effect on the width of the items. Falls back to Spacing. |
| VerticalSpacingXs | string? | null | Defines the vertical spacing between the rows of the grid from the extra small breakpoint (from 0px) upwards. The value keeps applying to every wider breakpoint until another one replaces it, and it takes precedence over SpacingXs. |
| VerticalSpacingSm | string? | null | Defines the vertical spacing between the rows of the grid from the small breakpoint (from 600px) upwards. The value keeps applying to every wider breakpoint until another one replaces it, and it takes precedence over SpacingSm. |
| VerticalSpacingMd | string? | null | Defines the vertical spacing between the rows of the grid from the medium breakpoint (from 960px) upwards. The value keeps applying to every wider breakpoint until another one replaces it, and it takes precedence over SpacingMd. |
| VerticalSpacingLg | string? | null | Defines the vertical spacing between the rows of the grid from the large breakpoint (from 1280px) upwards. The value keeps applying to every wider breakpoint until another one replaces it, and it takes precedence over SpacingLg. |
| VerticalSpacingXl | string? | null | Defines the vertical spacing between the rows of the grid from the extra large breakpoint (from 1920px) upwards. The value keeps applying to every wider breakpoint until another one replaces it, and it takes precedence over SpacingXl. |
| VerticalSpacingXxl | string? | null | Defines the vertical spacing between the rows of the grid from the extra extra large breakpoint (from 2560px) upwards, and it takes precedence over SpacingXxl. |
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. |
| 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. |
| Id | string? | null | Gets or sets the unique identifier for the component's root element. |
| IsEnabled | bool | true | Gets or sets a value indicating whether the component is enabled and can respond to user interaction. |
| 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. |
BitGridItem properties
A cell of a BitGrid, holding the content of one area of the layout and stating how many columns of the grid that area covers.
| Name | Type | Default value | Description |
|---|---|---|---|
| AlignSelf | BitAlignment? | null | Defines the vertical alignment of this item within its row, overriding the VerticalAlign of the grid for this item alone (the CSS align-self). |
| Auto | bool | false | Sizes the item to its own content instead of to a number of columns. Takes precedence over Grow and over every span of the item, and is the base of the mobile first chain the AutoXs to AutoXxl and GrowXs to GrowXxl parameters carry upwards. |
| AutoXs | bool? | null | Sizes the item to its own content from the extra small breakpoint (from 0px) upwards. The value keeps applying to every wider breakpoint until another one replaces it, and false gives the item its columns back. |
| AutoSm | bool? | null | Sizes the item to its own content from the small breakpoint (from 600px) upwards. The value keeps applying to every wider breakpoint until another one replaces it, and false gives the item its columns back. |
| AutoMd | bool? | null | Sizes the item to its own content from the medium breakpoint (from 960px) upwards. The value keeps applying to every wider breakpoint until another one replaces it, and false gives the item its columns back. |
| AutoLg | bool? | null | Sizes the item to its own content from the large breakpoint (from 1280px) upwards. The value keeps applying to every wider breakpoint until another one replaces it, and false gives the item its columns back. |
| AutoXl | bool? | null | Sizes the item to its own content from the extra large breakpoint (from 1920px) upwards. The value keeps applying to every wider breakpoint until another one replaces it, and false gives the item its columns back. |
| AutoXxl | bool? | null | Sizes the item to its own content from the extra extra large breakpoint (from 2560px) upwards, and false gives the item its columns back. |
| AutoOffset | bool | false | Pushes this item to the end edge of its row by turning every column left over before it into the offset. Takes precedence over Offset and over every per breakpoint offset, and follows the edge the row starts at exactly as Offset does. |
| AutoOffsetXs | bool? | null | Pushes this item to the end edge of its row from the extra small breakpoint (from 0px) upwards. The value keeps applying to every wider breakpoint until another one replaces it, and false hands the room back to Offset. |
| AutoOffsetSm | bool? | null | Pushes this item to the end edge of its row from the small breakpoint (from 600px) upwards. The value keeps applying to every wider breakpoint until another one replaces it, and false hands the room back to Offset. |
| AutoOffsetMd | bool? | null | Pushes this item to the end edge of its row from the medium breakpoint (from 960px) upwards. The value keeps applying to every wider breakpoint until another one replaces it, and false hands the room back to Offset. |
| AutoOffsetLg | bool? | null | Pushes this item to the end edge of its row from the large breakpoint (from 1280px) upwards. The value keeps applying to every wider breakpoint until another one replaces it, and false hands the room back to Offset. |
| AutoOffsetXl | bool? | null | Pushes this item to the end edge of its row from the extra large breakpoint (from 1920px) upwards. The value keeps applying to every wider breakpoint until another one replaces it, and false hands the room back to Offset. |
| AutoOffsetXxl | bool? | null | Pushes this item to the end edge of its row from the extra extra large breakpoint (from 2560px) upwards, and false hands the room back to Offset. |
| ChildContent | RenderFragment? | null | The content of the Grid item. |
| ColumnSpan | int? | null | Number of columns this item should fill. A span of 0 is an item that is not shown at all. When not set, the item falls back to the Span of its grid. |
| Element | string? | null | The custom html element used for the root node. The default is "div". |
| Grow | bool | false | Lets the item grow into whatever width is left over in its row, sharing it equally with the other items that grow. It is the base of the mobile first chain the GrowXs to GrowXxl and AutoXs to AutoXxl parameters carry upwards. |
| GrowXs | bool? | null | Lets the item grow into whatever width is left over in its row from the extra small breakpoint (from 0px) upwards. The value keeps applying to every wider breakpoint until another one replaces it, and false gives the item its columns back. |
| GrowSm | bool? | null | Lets the item grow into whatever width is left over in its row from the small breakpoint (from 600px) upwards. The value keeps applying to every wider breakpoint until another one replaces it, and false gives the item its columns back. |
| GrowMd | bool? | null | Lets the item grow into whatever width is left over in its row from the medium breakpoint (from 960px) upwards. The value keeps applying to every wider breakpoint until another one replaces it, and false gives the item its columns back. |
| GrowLg | bool? | null | Lets the item grow into whatever width is left over in its row from the large breakpoint (from 1280px) upwards. The value keeps applying to every wider breakpoint until another one replaces it, and false gives the item its columns back. |
| GrowXl | bool? | null | Lets the item grow into whatever width is left over in its row from the extra large breakpoint (from 1920px) upwards. The value keeps applying to every wider breakpoint until another one replaces it, and false gives the item its columns back. |
| GrowXxl | bool? | null | Lets the item grow into whatever width is left over in its row from the extra extra large breakpoint (from 2560px) upwards, and false gives the item its columns back. |
| Offset | int? | null | Number of columns to leave empty before this item, measured in the columns of the grid with the gaps included. The room is left on the edge the row starts at, so it indents from the right in a right-to-left grid and from the other end of either once the grid is Reversed. |
| OffsetXs | int? | null | Number of columns to leave empty before this item in the extra small breakpoint (from 0px). |
| OffsetSm | int? | null | Number of columns to leave empty before this item in the small breakpoint (from 600px). |
| OffsetMd | int? | null | Number of columns to leave empty before this item in the medium breakpoint (from 960px). |
| OffsetLg | int? | null | Number of columns to leave empty before this item in the large breakpoint (from 1280px). |
| OffsetXl | int? | null | Number of columns to leave empty before this item in the extra large breakpoint (from 1920px). |
| OffsetXxl | int? | null | Number of columns to leave empty before this item in the extra extra large breakpoint (from 2560px). |
| Order | int? | null | Defines the position of this item among its siblings, regardless of where it is written. The value can be negative, and only the painted order changes. |
| OrderXs | int? | null | Defines the position of this item among its siblings in the extra small breakpoint (from 0px). |
| OrderSm | int? | null | Defines the position of this item among its siblings in the small breakpoint (from 600px). |
| OrderMd | int? | null | Defines the position of this item among its siblings in the medium breakpoint (from 960px). |
| OrderLg | int? | null | Defines the position of this item among its siblings in the large breakpoint (from 1280px). |
| OrderXl | int? | null | Defines the position of this item among its siblings in the extra large breakpoint (from 1920px). |
| OrderXxl | int? | null | Defines the position of this item among its siblings in the extra extra large breakpoint (from 2560px). |
| Xs | int? | null | Number of columns this item should fill in the extra small breakpoint (from 0px). The value keeps applying to every wider breakpoint until another one replaces it, and 0 hides the item from this breakpoint upwards. |
| Sm | int? | null | Number of columns this item should fill in the small breakpoint (from 600px). The value keeps applying to every wider breakpoint until another one replaces it, and 0 hides the item from this breakpoint upwards. |
| Md | int? | null | Number of columns this item should fill in the medium breakpoint (from 960px). The value keeps applying to every wider breakpoint until another one replaces it, and 0 hides the item from this breakpoint upwards. |
| Lg | int? | null | Number of columns this item should fill in the large breakpoint (from 1280px). The value keeps applying to every wider breakpoint until another one replaces it, and 0 hides the item from this breakpoint upwards. |
| Xl | int? | null | Number of columns this item should fill in the extra large breakpoint (from 1920px). The value keeps applying to every wider breakpoint until another one replaces it, and 0 hides the item from this breakpoint upwards. |
| Xxl | int? | null | Number of columns this item should fill in the extra extra large breakpoint (from 2560px). A value of 0 hides the item from this breakpoint upwards. |
BitAlignment enum
| Name | Value | Description |
|---|---|---|
| Start | 0 | |
| End | 1 | |
| Center | 2 | |
| SpaceBetween | 3 | |
| SpaceAround | 4 | |
| SpaceEvenly | 5 | |
| Baseline | 6 | |
| Stretch | 7 |
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.