Skip to content
# Spacer ## Description The purpose of the BitSpacer is to generate space between other components inside a flex container. Left on its own it is flexible: it swallows the leftover room of the container and pushes its neighbours apart, and Grow shares that room out between several spacers in proportion, while MinGap puts a floor under it so its neighbours never touch. Given Width, Height, Gap or Size it becomes a fixed space instead, in pixels, in any CSS length or on the spacing scale of the theme, on the horizontal or the vertical axis. The element it renders is empty and hidden from assistive technologies. ## Parameters | Name | Type | Default Value | Description | | :--- | :--- | :------------ | :---------- | | Element | `string?` | null | Gets or sets the custom html element used for the root node, "div" by default. This is what lets a spacer sit in a container that only accepts specific children, such as an "li" inside a list-based toolbar or menu, without breaking the markup of that container. | | Gap | `string?` | null | Gets or sets the fixed amount of space the spacer generates, using any CSS length value (for example "1rem", "5%", or "var(--my-gap)"). The space is created along the inline (horizontal) axis, or along the block (vertical) axis when Vertical is set. It takes precedence over Width, Height and Size on the axis it targets, and like them it turns the spacer from a flexible one into a fixed one, so Grow and MinGap no longer apply. | | Grow | `string?` | null | Gets or sets how much of the leftover space of the container this spacer takes compared to its siblings (the CSS flex-grow factor), 1 by default. Two spacers with the factors "1" and "2" split the leftover space of the container one third to two thirds. It is ignored as soon as the spacer is given a fixed size through Gap, Width, Height or Size. | | Height | `int?` | null | Gets or sets the fixed amount of space the spacer generates along the block (vertical) axis, in pixels. This is the parameter to reach for inside a vertical (column) layout, where the inline-axis Width creates no visible space. Setting it turns the spacer from a flexible one into a fixed one, so Grow and MinGap no longer apply. | | MinGap | `string?` | null | Gets or sets the smallest amount of space a flexible spacer keeps when the container runs out of room, using any CSS length value. It applies to the inline (horizontal) axis, or to the block (vertical) axis when Vertical is set. It only concerns a flexible spacer, so it is ignored as soon as the spacer is given a fixed size through Gap, Width, Height or Size. | | Size | `BitSize?` | null | Gets or sets the fixed amount of space the spacer generates, picked from the spacing scale of the theme, so the resulting length follows the spacing unit and the density of the current theme instead of being hardcoded. It is created along the inline (horizontal) axis, or along the block (vertical) axis when Vertical is set, and like the other fixed sizes it turns the spacer from a flexible one into a fixed one, so Grow and MinGap no longer apply. Gap, Width and Height are more specific, so they take precedence over it. | | Vertical | `bool` | false | Gets or sets a value indicating whether Gap, Size and MinGap apply to the block (vertical) axis instead of the inline (horizontal) one. A flexible spacer does not need this parameter: it always grows along the main axis of its container, whichever that is. | | Width | `int?` | null | Gets or sets the fixed amount of space the spacer generates along the inline (horizontal) axis, in pixels. The space follows the text direction of the spacer, so in a right-to-left context it is created on the right side. Setting it turns the spacer from a flexible one into a fixed one, so Grow and MinGap no longer apply. | | 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. | ## 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 ### BitSize Enum | Name | Value | Description | | :--- | :--- | :---------- | | Small | 0 | The small size. | | Medium | 1 | The medium size. | | Large | 2 | The large size. | ### 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. | ## Examples \n**Basic**: ```razor
Title
Start
End
``` \n**Fixed size**: ```razor
1rem
4ch
10%
end
``` \n**Vertical**: ```razor
Height 8
Height 32
Vertical Gap 3rem
Flexible
Bottom
``` \n**Grow**: ```razor
A
B
C
A
B
C
``` \n**Minimum size**: ```razor
MinGap
2rem
No
MinGap
``` \n**Element**: ```razor
  • Home
  • Products
  • Sign in
``` \n**Size**: ```razor
Small
Medium
Large
End
Vertical Small
Vertical Large
End
``` \n**Style & Class**: ```razor
Style
Class
End
``` \n**RTL**: ```razor
شروع
میانه
پایان
Start
Middle
Start
Middle
```