Progress
Loading
Eighteen pure-CSS loading animations - spinners, dots, bars and shapes - sharing one API: color, size, stroke thickness, a label on any side, speed, pause, a delay that keeps quick work from flashing a loader, and a live region that announces the wait.
Notes
A loader says work is under way without saying how much is left, which suits a wait of about one to ten seconds. For shorter work show nothing - hold it back with Delay. When the shape of the content is known, a BitShimmer reads better; when the work can report its progress, or runs longer, use a determinate BitProgress.
Usage
Every example is live. Open its code to see exactly what produced the component running underneath.
Basic
Label
Speed & Paused
2 is twice as fast) and still
composes with the reduced-motion preference. Paused freezes it on the current frame: the layout and
the live region stay as they are, so use it only while the work is really still under way.
Delay
Thickness
Inline
Fetching the latest results Loading please wait.
Syncing Loading
Overlay
aria-busy for as long as it is stale - the content alone, since a busy region holds
back its announcements and the loader's own has to get through.
Accessibility
role="status" live region, so its text is announced when the loader appears,
and the drawing is aria-hidden. That text is the Label, or a visually hidden
"Loading" that AriaLabel rewords. Role="none" silences a decorative loader whose
surroundings already report the wait, AriaLive="assertive" interrupts the screen reader, and
Role="progressbar" turns it into an indeterminate progress bar named by its label. Mark
the content being replaced aria-busy, as in Overlay.
Cascading parameters
Color
currentColor included - which is what lets an inline
loader, or one on an overlay, take the color of the text around it - and applies only while Color is unset.
Size
Style & Class
:root they restyle every loader, on an ancestor the loaders inside it,
and on a loader's Style that loader alone. The whole drawing is laid out from
--bit-Loading-size, so it resizes in CSS with any length, em and
rem included.
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 that one alone. Leave a variable unset and the component falls back to the theme token beside it.
BitLoading CSS variables
| Name | Default value | Description |
|---|---|---|
| --bit-Loading-color | Color / CustomColor, or the primary color | Color of the drawing. |
| --bit-Loading-track-color | transparent | The full circle under the moving arcs of the Ring, DualRing and Xbox loaders. |
| --bit-Loading-size | Size / CustomSize, or 64px (1em when Inline) | Width and height of the drawing, which is laid out from it. Any CSS length, em and rem included. |
| --bit-Loading-thickness | Thickness, or the width each drawing was made with | Stroke width of the Ring, DualRing, Ripple, Xbox and Spinner loaders. |
| --bit-Loading-speed | Speed, or 1 | Multiplier of the animation speed; a positive number. |
| --bit-Loading-gap | spacing(1) | Room between the drawing and the label. |
| --bit-Loading-label-color | The surrounding text color | Color of the label. |
| --bit-Loading-label-font-size | Per Size, from the type ramp | Text size of the label. |
| --bit-Loading-label-font-weight | $tg-fw-regular | Text weight of the label. |
API
Every parameter, public member, sub-class and enum this component exposes.
BitLoading parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| AriaLive | string? | null | The aria-live politeness of the root live region. Falls back to "polite" for the default status role and to the role's own politeness otherwise; ignored while the loader is decorative. |
| Classes | BitLoadingClassStyles? | null | Custom CSS classes for different parts of the loading component. |
| Color | BitColor? | null | The theme color of the drawing. |
| CustomColor | string? | null | Any CSS color for the drawing, currentColor included. Only applies while Color is unset. |
| CustomSize | int? | null | The size of the drawing in px; the label scales along within a readable range. Only applies while Size is unset. Zero and negative values are ignored. |
| Delay | int | 0 | How long, in ms, the loader waits before showing anything, so quick work never flashes it. Changing the value restarts the wait. |
| Inline | bool | false | Lays the loader out on the current line of text, a button or a table cell, at the size of the text (1em) unless Size or CustomSize is set. |
| Label | string? | null | The status text shown beside the drawing and announced by screen readers. |
| LabelPosition | BitLabelPosition? | null | The side of the drawing the label sits on: Top by default, End for an Inline loader. Start and End follow the writing direction. |
| LabelTemplate | RenderFragment? | null | Custom content for the label. Takes the place of Label. |
| Paused | bool | false | Freezes the animation on its current frame, keeping the layout and the live region as they are. |
| Role | string? | null | The ARIA role of the root. Falls back to "status", a live region; "progressbar" makes an indeterminate progress bar named by AriaLabel, Label or "Loading"; "none" makes the loader decorative. |
| Size | BitSize? | null | The size of the loader: 40px, 64px or 88px, with the label on the matching step of the type ramp. |
| Speed | double? | null | A multiplier of the animation speed: 2 is twice as fast. Composes with reduced motion. Zero and negative values are ignored. |
| Styles | BitLoadingClassStyles? | null | Custom CSS styles for different parts of the loading component. |
| Thickness | int? | null | The stroke width in px of the Ring, DualRing, Ripple, Xbox and Spinner loaders. Does not scale with the size. Zero and negative values are ignored. |
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. |
BitLoadingClassStyles properties
| Name | Type | Default value | Description |
|---|---|---|---|
| Root | string? | null | Custom CSS classes/styles for the root element of the BitLoading components. |
| Container | string? | null | Custom CSS classes/styles for the child container of the BitLoading components. |
| Child | string? | null | Custom CSS classes/styles for the child element(s) of the BitLoading components. |
| Label | string? | null | Custom CSS classes/styles for the label of the BitLoading components. |
| ScreenReaderText | string? | null | Custom CSS classes/styles for the visually hidden text a labelless BitLoading component announces to assistive technology. |
BitColor enum
| Name | Value | Description |
|---|---|---|
| Primary | 0 | Info 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. |
BitLabelPosition enum
| Name | Value | Description |
|---|---|---|
| Top | 0 | The label shows above the animation. |
| End | 1 | The label shows at the end side of the animation, which follows the direction of the writing. |
| Bottom | 2 | The label shows below the animation. |
| Start | 3 | The label shows at the start side of the animation, which follows the direction of the writing. |
BitSize enum
| Name | Value | Description |
|---|---|---|
| Small | 0 | The small size, which renders a 40px loading component. |
| Medium | 1 | The medium size, which renders a 64px loading component. |
| Large | 2 | The large size, which renders an 88px loading 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.