Utilities
Element
BitElement renders any tag - a div by default, or an anchor, a button, an input, an SVG shape, a custom element - with the parameters every bit BlazorUI component takes. Other attributes and events are splatted onto the tag, disabling follows what the tag supports, NoWrapper makes it a conditional wrapper, and the stopPropagation / preventDefault modifiers Razor only allows on plain elements are parameters.
Usage
Every example is live. Open its code to see exactly what produced the component running underneath.
Basic
div. Element names any other tag and is used as
written. A value that is not a valid tag name (whitespace, a <, other symbols) falls back to
the div instead of reaching the markup.
A heading (h4)
A paragraph (p) with a highlighted (mark) word.
A quotation (blockquote)
Attributes & events
href, placeholder, role,
aria-*, data-*, @onclick, @oninput, ... - is splatted
onto the rendered tag. The shared parameters (Id, AriaLabel, TabIndex, ...) win over
the attribute of the same name.
SVG & custom elements
linearGradient, clipPath) work
inside an svg. A custom element (any name with a dash) passes through untouched.
Void elements
input, img, hr, br, ...) render without a
closing tag, and their ChildContent is left out rather than emitted as invalid markup.
Event modifiers
:stopPropagation and :preventDefault on plain elements, so they
are parameters here. StopPropagation and PreventDefault apply to the click;
StopPropagationEvents and PreventDefaultEvents take any other event names (with or without
the on prefix) and apply whether or not a handler is attached.
Dynamic element
No wrapper
Element reference
ElementReference for JS interop, and
FocusAsync focuses it - optionally without scrolling. A non-focusable tag needs a TabIndex.
Both are no-ops while NoWrapper is set or before the first render.
Disabled
aria-disabled; form elements also get the native disabled, other tags
tabindex="-1". An anchor with an href loses it but gets role="link",
so it is announced as a disabled link; an area keeps its href and has its clicks'
default action prevented instead. Any disabled tag drops its activation handlers (@onclick,
@onkeydown, @onpointerdown, ...), so neither a screen reader's click nor an event
bubbling up from its content can run them. Screen readers ignore aria-disabled on a generic tag,
so give it a role. Content inside keeps its own tab stops - use a fieldset to disable a whole form.
Visibility
Cascading parameters
button that keeps its clicks from the card, except the last one.
Style & Class
style or class attribute
instead of replacing it.
:root, on an ancestor, or on the Style of one element - and a value set on an element
also reaches every element inside it.
RTL
dir attribute (and the bit-rtl class) on any tag.
یک نقل قول راستچین.
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 that one alone. Leave a variable unset and the component falls back to the theme token beside it.
BitElement CSS variables
| Name | Default value | Description |
|---|---|---|
| --bit-Element-disabled-opacity | --bit-opa-dis | Opacity of a disabled element. Set it to 1 to keep the tag's own look, for a wrapper whose content shows its own disabled state. It inherits, so the value also reaches every element inside: a disabled element nested in a wrapper set to 1 needs a value of its own (e.g. var(--bit-opa-dis)) to dim again. |
API
Every parameter, public member, sub-class and enum this component exposes.
BitElement parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| ChildContent | RenderFragment? | null | The content of the element. Not rendered into a void element (input, img, br, hr, ...). |
| Element | string? | null | The tag to render, used as written (SVG and custom elements included). A value that is not a valid tag name - an ASCII letter followed by letters, digits, "-", "_", "." or ":" - falls back to the default "div". |
| NoWrapper | bool | false | Renders only the content, without the tag. Everything describing the tag is ignored, except a Collapsed Visibility, which drops the content too. |
| PreventDefault | bool | false | Prevents the default browser action of the click (@onclick:preventDefault). |
| PreventDefaultEvents | IEnumerable<string>? | null | The events whose default browser action is prevented, named with or without the "on" prefix. Naming "click" wins over PreventDefault. |
| StopPropagation | bool | false | Stops the click from bubbling up to the ancestors (@onclick:stopPropagation). |
| StopPropagationEvents | IEnumerable<string>? | null | The events stopped from bubbling up, named with or without the "on" prefix. Naming "click" wins over StopPropagation. |
BitElement public members
| Name | Type | Default value | Description |
|---|---|---|---|
| FocusAsync | ValueTask | Focuses the rendered element; the overload taking preventScroll focuses it without scrolling it into view. The element must be focusable (a focusable tag or one with a TabIndex). Does nothing while NoWrapper is set or before the first render. |
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. |
| 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. |
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.