Skip to content

Inputs

Rating

Bit.BlazorUI

BitRating turns an opinion into a row of stars: hover to preview what a click would give, click to commit it. Precision splits every item into as many selectable steps as you ask for, so halves, quarters and tenths are reachable with the pointer and with the arrow keys alike, while a bound value of any precision is always drawn exactly - which is what makes the same component the read-only 4.3-out-of-5 summary beside a review count. The whole row is a single tab stop following the WAI-ARIA radiogroup pattern.

Usage

Every example is live. Open its code to see exactly what produced the component running underneath.

Basic

Left unbound, the rating keeps its own state and DefaultValue only picks where that state starts. Disabling it greys the items out; ReadOnly keeps them at full contrast but frozen - the mode a rating spends most of its life in, summarizing what other people already rated. The difference runs deeper than the styling: a read-only rating stops being a group of choices and is announced as a single labelled image. Note its fractional value - partial fills are rendered whether or not the user could ever have picked them.

Basic:

DefaultValue:

Disabled:

ReadOnly:

Label & item titles

Label names the rating - and since a row of stars carries no text of its own, it is also what names it for a screen reader. Required marks it with an asterisk, LabelPlacement moves it beside the items for a compact row, and LabelTemplate replaces it with markup of your own, below a caption that spells the value out in words. Description is the hint under the items, pointed at by aria-describedby so it is announced after the name rather than as part of it, and DescriptionTemplate replaces it with markup while keeping that role. ItemTitles gives each item its own tooltip, in order, and those words double as the accessible name of the item; items past the end of the list fall back to their position.

How would you rate your stay?
Hover a star to see what it means.

Cleanliness

Staff
Averaged over 1,034 stays, updated nightly.

Good

Max

Max is both the highest value the rating accepts and the number of items it renders. Five is the familiar default; the items wrap when the row runs out of room, which is what keeps a 100-point rating usable inside a narrow container, and a value above the Max is pulled back down to it so the scale can be tightened at runtime. A Max of 1 turns the rating into the compact single-star badge beside a numeric score.

Max is 1 (a compact review summary):

Max is 3:

Max is 6:

Max is 100:

Vertical

Vertical stacks the items into a column and fills it from the bottom up, so that "more" is up - the direction ArrowUp already means. A fractional value fills its item from the bottom edge, the slices of a fine Precision are stacked the same way, and the group announces itself as vertically oriented.

Vertical:

Vertical with a half precision:
3.5 of 5

Precision

Precision is the smallest change the user can make, as a fraction of a single item: 1 allows whole items only, 0.5 adds halves, 0.1 makes every tenth selectable. Each item is covered by that many transparent slices, so the half a pointer lands on is the half that gets committed, and the arrow keys step by the same amount. A precision that does not divide an item evenly is rounded to the closest number of equal steps, and an item is never split into more than a hundred. It constrains what the user can pick, never what can be shown: a value bound from elsewhere is always drawn at its exact precision. It also sets the floor of the scale - the smallest rating that can still be given is one step, so a half-star rating reaches 0.5 without having to open up the unrated 0 that AllowZeroStars is for.

Half (Precision="0.5"):
2.5 of 5

Quarter (Precision="0.25"):
3.25 of 5

Exact (Precision="0.1"):
3.7 of 5

Clearing

A rating starts at its smallest step - a whole item at the default Precision - unless it is told that "not rated" is a legitimate answer. AllowZeroStars says exactly that: a value of 0 is kept instead of being pulled up, so the rating can start empty. That makes 0 part of the scale rather than an action, so the keys that reach the ends of the range - Home and 0 - reach it while the pointer, which always commits at least one step, cannot.

AllowClear is clearing as an action: clicking the item that is already selected, or pressing Delete or Backspace, returns the rating to 0 - which is why it opens up the 0 on its own. Because the preview is always the value a click would commit, the items empty while the pointer rests on the committed value, so clearing is discovered rather than explained.

Default (0 is pulled up to the smallest step):

Default with a half Precision (the floor is half an item, not a whole one):
0.5 of 5

AllowZeroStars (starts empty; only Home or the 0 key gets back there):
0 of 5

AllowClear (hover the selected item to watch the row empty, then click - or press Delete):

HighlightSelectedOnly

By default a rating is cumulative: picking the fourth item fills the first four, because four stars means "four out of five". HighlightSelectedOnly switches to a scale of standalone choices where only the matching item is filled - the right reading when the items are faces, moods or grades rather than a quantity. A fractional value still fills its own item by the fraction it covers, so the mode composes with Precision instead of rounding against it.

Cumulative (default):

HighlightSelectedOnly:

Hover preview

While the pointer is over the items the rating previews the value a click would commit, painting it in the hover shade so it reads as a proposal rather than as the committed value; leaving restores what is bound. OnHoverChange reports that previewed value as it changes, and null once the pointer leaves - which is all a caption needs to follow the pointer, down to a half step at a fractional Precision. NoHoverPreview turns off the preview the component paints, for a page that competes with it or draws one of its own - the items still grow under the pointer and dip under a press, since those are affordances and not values, and OnHoverChange goes on reporting. The press is what carries a touch device, which has no hover to preview with at all.

Hover over the stars:
Normal

NoHoverPreview (the stars stay put, the caption still follows the pointer):

Icons

SelectedIconName and UnselectedIconName replace the pair of built-in star glyphs, which is what lets the same component read as a like, a heart or a checklist. The two icons are drawn on top of each other and the selected one is clipped to the fill percentage, so the pair works best when both glyphs share an outline - a hollow shape and its filled twin.

GetSelectedIcon and GetUnselectedIcon answer for a single position instead of the whole scale, which turns a rating into one that changes shape as it fills. Each receives the one-based position and may return null to fall back to the pair above, so only the positions that need their own glyph have to be answered - and since the component keeps drawing the item, the two-layer partial fill of a fractional value goes on working. For icons from an external library see External Icons.

Heart:

Checkbox:

Thumbs, down for the first two and up for the rest (GetSelectedIcon):

A different face at every step (with HighlightSelectedOnly):

ItemTemplate

ItemTemplate replaces the pair of icons with content of your own while the BitRating keeps everything around it: the hit areas, the hover preview, the keyboard handling and the accessibility. The template receives a BitRatingItemContext - the item's Index, the Percentage it is filled by, whether it IsFull or merely IsSelected, whether it IsCurrent (the one the shown value lands in, which the numbered scale below rings), and both the previewed DisplayValue and the committed Value. A template renders as a whole, so a partial fill is yours to express if it matters; when all you need is a different glyph per position, GetSelectedIcon keeps the built-in one. The drawing is hidden from assistive technologies just as the built-in glyphs are, so the numbers and faces below are not appended to the names the items already carry.

Numbered scale:

Mood faces (with HighlightSelectedOnly):

Binding

A one-way Value makes the rating a pure display of whatever the page decides - the toggle below drives it and clicking the stars does nothing, because there is nowhere for the new value to go. @bind-Value completes the circuit both ways. Notice the number field can push a fractional value into a rating whose Precision is 1.

One-way:
0 of 5

Two-way:

Events

OnChange fires after a new value lands, which is what an uncontrolled rating reports its result through. OnChanging runs first and can stop the change: setting Cancel on the BitRatingChangeArgs keeps the current value, and since the callback is awaited it can take long enough to ask the user a question. The args carry both the incoming Value and the OldValue, so the decision can depend on the direction of the change - the second rating below refuses to be lowered. OnFocusIn and OnFocusOut report the focus arriving at and leaving the rating as a whole rather than each item, so moving along the scale with the arrow keys does not read as leaving and re-entering it.

OnChange:

OnChanging (this one refuses to go down):

OnFocusIn & OnFocusOut (tab to it, then arrow along it):

Validation

Inside an EditForm the rating is a form field like any other: it joins the EditContext, reports its changes to it, and turns red while the value is invalid. Combined with AllowZeroStars, a Range annotation starting at 1 turns "pick a rating" into a required question - the form starts unrated and stays unsubmittable. Required announces that expectation ahead of the failure and marks the label with an asterisk. The value travels in a hidden number input, so Name also makes the rating readable by a plain form post.

aria-invalid says that something is wrong but not what, so the failure message is given an id and pointed at from the rating. A splatted aria-describedby is carried over rather than replaced - both it and the component's own Description are kept, since the attribute is a list - so the reason is announced with the field instead of only being visible under it.

Your rate
0 of 5

Accessibility

An interactive rating is a WAI-ARIA radiogroup of radio items: the whole row is a single tab stop landing on the selected item, and from there the keyboard covers the scale, stepping by the Precision.
  • → / ↑ raise the value by one step, ← / ↓ lower it
  • Shift with an arrow, or PageUp / PageDown, moves a whole item - so a rating split into tenths is five presses wide rather than fifty
  • Home / End jump to the ends of the scale
  • Space / Enter commit the item the focus is on, whole
  • 1 … 9 jump straight to that rating, and 0 to the bottom of the scale - which is the unrated 0 once AllowZeroStars or AllowClear has opened it up
  • Delete / Backspace clear it, where AllowClear permits
The horizontal arrows follow the reading direction and swap in RTL. A held Ctrl, Alt or Meta hands the key back to the page, so Alt+← still goes back, and Escape is left alone so a rating inside a modal does not clear itself on the way to dismissing it. Every item is a pointer target of at least 24×24 CSS pixels whatever the Size, and the fill survives a forced-colors palette, where it is re-established in system colors rather than left to color alone.

Name the group: a visible Label does it, and AriaLabel or AriaLabelledBy where the name is already written elsewhere on the page. AriaLabelFormat names each item, with {0} as the item and {1} as the max - "Select 3 of 5 stars"; without it an item falls back to its ItemTitles tooltip and then to its position, so no item is ever nameless. GetAriaLabel builds the group's name from the current value and the max. ValueTextFormat rewords what is announced for a value no radio can carry - a fractional one, and the value a read-only rating adds to its own name. AutoFocus hands the rating the focus as the page renders.

Tab to it, then use the arrow, Page and digit keys:

GetAriaLabel (inspect the aria-label of the read-only rating):

Overall satisfaction

Visibility

Visibility decides how the rating disappears: Hidden keeps its box and only stops painting it, so the layout around it does not move, while Collapsed removes the box entirely. The brackets below mark where each one sits.

Visible: [
]
Hidden: [ ]
Collapsed: [ ]

Score-based styling

The parameters are re-read on every render, so they can be computed from the very value the rating is bound to - which is all it takes to restyle the scale by the score it shows. The first rating below derives its Color from its own value, turning from red through orange to green as the score climbs; the second derives its icons the same way, so a low score frowns and a high one smiles. No dedicated API is involved.

The color follows the score:

The icon follows it too:

Cascading parameters

BitParams carries a BitRatingParams down to every rating under it, so a review list, a card or a whole page sets the shared scale, glyphs and mode once instead of on every rating. What it carries is a default and not an override: a rating that writes a parameter for itself keeps its own value, and only what it left unset is filled in from the cascade - parameter by parameter, which is how the last rating below steps out of the group it is in without the group knowing about it.



Rate it yourself

Outside the cascade, and back to the defaults:

Color

Color picks the theme color the filled part of the items is painted in, with Primary as the default; the hover shade, the press shade and the focus ring all come from the same role. The unfilled part stays neutral whatever the color is, so it keeps reading as "not rated yet" instead of as a second, dimmer accent. The semantic colors tie the rating to what the score means, while the Background, Foreground and Border families keep it legible on non-default surfaces like the inverted panel below.

3.5 of 5
Primary
3.5 of 5
Secondary
3.5 of 5
Tertiary
3.5 of 5
Info
3.5 of 5
Success
3.5 of 5
Warning
3.5 of 5
SevereWarning
3.5 of 5
Error

3.5 of 5
PrimaryBackground
3.5 of 5
SecondaryBackground
3.5 of 5
TertiaryBackground

3.5 of 5
PrimaryForeground
3.5 of 5
SecondaryForeground
3.5 of 5
TertiaryForeground
3.5 of 5
PrimaryBorder
3.5 of 5
SecondaryBorder
3.5 of 5
TertiaryBorder

External Icons

SelectedIcon and UnselectedIcon take a BitIconInfo instead of a built-in icon name, which is how icons from an external library are used. BitIconInfo.Fa and BitIconInfo.Bi build the class names for FontAwesome and Bootstrap Icons, BitIconInfo.Css takes whatever classes you hand it, and a plain string works too. They take precedence over SelectedIconName / UnselectedIconName, and the same type is what the per-item GetSelectedIcon callback returns. Remember to reference the stylesheet of the icon library itself.


FontAwesome (stars):
3.5 of 5

FontAwesome (hearts):
3.5 of 5

Bootstrap (stars):
3.5 of 5

Bootstrap (hearts):
3.5 of 5

Size

Size scales the whole control - the glyphs, the label and the description - from the Small that fits inline next to a line of text to the Large that carries a rating asked as the main question on a page. Medium is the default. The pointer target of an item never drops below 24×24 CSS pixels, so a smaller size buys a smaller glyph rather than a harder one to hit.

Small
Fits inline beside body text.

Medium
The default.

Large
For the question a page is built around.

Style & Class

Style and Class land on the root. Styles and Classes reach the parts by name - Root, LabelContainer, Label, Description, Container, Button, IconContainer, SelectedIcon and UnselectedIcon - so the filled and unfilled halves can be styled apart from each other. Prefer Classes where your CSS should own states such as hover and focus, which inline styles cannot express. Each item also carries data-is-current, which marks the one the shown value lands in - the fourth of a 3.5, and the one under the pointer while a preview is running - so the item being picked can be told apart from the run of filled ones behind it.

Component's Style & Class:




Styles & Classes:

3.5 of 5

Classes
3.5 of 5


data-is-current (the item being picked is ringed):

3.5 of 5


The rating also reads a set of CSS variables off its root for what no parameter covers. They inherit, so a value on :root or any ancestor re-skins every rating below it, and one on the Style of an instance re-skins that one alone.

Its own palette:
3.5 of 5

Bigger glyphs, room between them, and a livelier press (hold an item down):

Shrunk to the glyph and made inline, for a rating that sits inside a line of text:
Rated by 1,034 people.

Set once on an ancestor, inherited by every rating inside it:

RTL

Setting Dir to Rtl mirrors the whole rating: the first item moves to the right, the partial fill of a fractional value grows from the right edge of its item, the slices of a fine Precision are laid out from that same edge, and the horizontal arrow keys swap so that ArrowLeft still means "more".


3.5 of 5

امتیاز شما

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.

BitRating CSS variables

Name Default value Description
--bit-Rating-color The Color role's main color Color of the filled part of the items.
--bit-Rating-unselected-color --bit-clr-fg-ter Color of the unfilled part of the items, which stays neutral whatever the Color is so that it keeps reading as "not rated yet".
--bit-Rating-hover-color The Color role's hover color Color of the filled part while the pointer is previewing a value over the items (pointer devices only).
--bit-Rating-active-color The Color role's active color Color of the filled part while an item is being pressed, which on a touch device - where there is no hover - is the only feedback a tap gets before the new value lands.
--bit-Rating-focus-color The Color role's focus color Color of the keyboard focus ring of an item.
--bit-Rating-disabled-color --bit-clr-fg-dis Color of both parts of the items, and of the label, when Disabled is true.
--bit-Rating-invalid-color --bit-clr-err (items), --bit-clr-err-focus (ring) Color of both parts of the items, and of the focus ring, while the value is invalid.
--bit-Rating-size Per size: --bit-siz-icon-sm / -md / -lg Size of the item glyphs, which the Size parameter otherwise picks. It does not move the label or the description, which have text sizes of their own.
--bit-Rating-target-size 1.5rem Smallest pointer target of an item on both axes, which the glyph is centred in - the 24px minimum of WCAG 2.2 (SC 2.5.8). Raise it for the roomier targets of a touch platform, or set it to 0 to shrink the items to the glyph and its padding, for a rating that has to sit inside a line of running text.
--bit-Rating-padding spacing(0.25) Padding of an item around its glyph, which only widens the item once it exceeds the target size.
--bit-Rating-gap 0 Extra room between the items, beyond their own padding.
--bit-Rating-radius --bit-shp-radius-control Corner radius of an item and of its focus ring.
--bit-Rating-hover-scale 1.1 How much the item under the pointer grows, which is the affordance that says the items are there to be pressed. A value of 1 turns it off.
--bit-Rating-active-scale 0.9 How much the item being pressed dips - it shrinks rather than grows, since a pointer has already grown it by hovering it. A value of 1 turns it off.
--bit-Rating-label-color --bit-clr-fg-pri Text color of the label.
--bit-Rating-label-font-size Per size: --bit-tpg-fs-xs / -sm / -md Text size of the label, which the Size parameter otherwise picks.
--bit-Rating-label-font-weight --bit-tpg-fw-semibold Text weight of the label.
--bit-Rating-label-gap spacing(1) Room between the label and the items, and between the items and the description.
--bit-Rating-description-color --bit-clr-fg-sec Text color of the description.
--bit-Rating-description-font-size Per size: --bit-tpg-fs-2xs / -xs / -sm Text size of the description, which the Size parameter otherwise picks.

API

Every parameter, public member, sub-class and enum this component exposes.

BitRating parameters

Name Type Default value Description
AllowClear bool false Lets the current value be cleared, by clicking the item that is already selected or by pressing Delete or Backspace. Clearing sets the value to 0, so it also makes 0 a reachable value the same way AllowZeroStars does.
AllowZeroStars bool false Puts the unrated 0 in the range of the rating, so a value of 0 is kept instead of being pulled up to the smallest step and the rating can start empty. The keys that reach the ends of the range - Home and the 0 key - reach it, while the pointer always commits at least one step and Delete stays behind AllowClear.
AriaLabelFormat string? null Names each individual rating item - not the rating as a whole - for screen readers. Placeholder {0} is the rating that item stands for, which is its one-based position, and placeholder {1} is the max. Without it an item is named by its ItemTitles tooltip, and failing that by its position in the scale.
AriaLabelledBy string? null The id of an element that names the rating as a whole, for a name that is already written somewhere on the page. It wins over every other source of the name, including the visible Label.
AutoFocus bool false If true, the rating automatically receives focus when the page renders.
Classes BitRatingClassStyles? null Custom CSS classes for different parts of the BitRating.
Color BitColor? null The general color of the rating, applied to the filled part of the items. The unfilled part stays neutral so it reads as "not rated yet" whichever color is picked.
Description string? null The hint shown under the items and pointed at by aria-describedby, for the instruction a row of stars cannot give by itself. It describes the rating rather than naming it, so it is announced after the label.
DescriptionTemplate RenderFragment? null Replaces the Description with custom content, which is still what describes the rating for assistive technologies.
GetAriaLabel Func<double, double, string>? null Names the rating as a whole from its current value and the max, which arrive as the first and the second argument. It is used whenever AriaLabel is not set, and like that label it wins over the visible Label. A read-only rating has to carry its value in its name, since its items are hidden behind that single name; this is how to word it.
GetSelectedIcon Func<int, BitIconInfo?>? null Chooses the selected (filled) icon of each rating item separately, from the one-based position of the item. Returning null falls back to SelectedIcon / SelectedIconName.
GetUnselectedIcon Func<int, BitIconInfo?>? null Chooses the unselected (empty) icon of each rating item separately, from the one-based position of the item. Returning null falls back to UnselectedIcon / UnselectedIconName.
HighlightSelectedOnly bool false Highlights only the item matching the current value instead of every item up to it, turning the rating into a scale of standalone choices rather than a cumulative one. A fractional value still fills its own item by the fraction it covers.
ItemTemplate RenderFragment<BitRatingItemContext>? null Replaces the default pair of icons of every rating item with custom content. The template draws the item and nothing else: the item keeps its hit area, hover preview, keyboard handling and name, and the drawing is hidden from assistive technologies as the built-in glyphs are.
ItemTitles IList<string>? null The native tooltips of the rating items, in order, shown when hovering over each one, and used as the accessible name of the item unless AriaLabelFormat overrides it. Items beyond the end of the list simply get no tooltip, and the items of a read-only or disabled rating take no pointer events, so their tooltips never appear there.
Label string? null The visible label of the rating, which also becomes its accessible name: a row of stars carries no text of its own, so without a label - or an AriaLabel - the group is announced without saying what is being rated. A required rating marks its label with an asterisk.
LabelPlacement BitPlacement? null Where the label sits relative to the items: above them by default, and beside them with Start or End for the compact single-line row.
LabelTemplate RenderFragment? null Replaces the Label with custom content, which still names the rating for assistive technologies the same way the plain label does.
Max int 5 Maximum rating, which is also the number of rendered items. Values below 1 are treated as 1.
NoHoverPreview bool false Turns off the preview that follows the pointer over the items and shows the value that a click would commit. Only the preview the component paints stops: OnHoverChange goes on reporting the hovered value.
OnChanging EventCallback<BitRatingChangeArgs> Callback invoked before the value of the rating changes, letting the change be cancelled by setting Cancel on the provided args.
OnFocusIn EventCallback<FocusEventArgs> Callback for when the rating receives the focus. It reports the focus arriving at the rating as a whole, not at each item, so moving along the scale does not raise it again.
OnFocusOut EventCallback<FocusEventArgs> Callback for when the focus leaves the rating.
OnHoverChange EventCallback<double?> Callback for when the hovered value changes, which is the value a click would commit. It receives null when the pointer leaves the rating, and keeps reporting under NoHoverPreview.
Precision double 1 The smallest change of the value the user can make, as a fraction of a single item. The default of 1 only allows whole items, 0.5 adds halves, 0.1 makes every tenth selectable; anything at or above 1, and anything at or below 0, leaves the items whole. It constrains what the user can pick, not what can be displayed, and it is also the floor of the scale unless AllowZeroStars or AllowClear opens up the unrated 0.
SelectedIcon BitIconInfo? null Icon for selected rating elements using external icon libraries (e.g. FontAwesome, Bootstrap Icons). Takes precedence over SelectedIconName when both are set.
SelectedIconName string? FavoriteStarFill Custom icon name for selected rating elements (Fluent UI). For external icon libraries, use SelectedIcon instead.
Size BitSize? null Size of the rating, which scales the item glyphs, the label and the description together.
Styles BitRatingClassStyles? null Custom CSS styles for different parts of the BitRating.
UnselectedIcon BitIconInfo? null Icon for unselected rating elements using external icon libraries (e.g. FontAwesome, Bootstrap Icons). Takes precedence over UnselectedIconName when both are set.
UnselectedIconName string? FavoriteStar Custom icon name for unselected rating elements (Fluent UI). For external icon libraries, use UnselectedIcon instead.
ValueTextFormat string? null The format of the spoken form of the current value, where placeholder {0} is the value and placeholder {1} is the max. It is what the live region of an interactive rating announces for a value no radio can carry, and what a read-only rating falls back to when it is given no other label. The default is "{0} of {1}".
Vertical bool false Stacks the rating items in a column instead of a row, filling from the bottom up so that "more" is up, the way the ArrowUp key means more.

BitInputBase parameters

Name Type Default value Description
DefaultValue TValue? null The default value of the input to be used in uncontrolled mode (i.e. when the Value is not bound), typically used alongside the OnChange callback.
DisplayName string? null Gets or sets the display name for this field.
InputHtmlAttributes IReadOnlyDictionary<string, object>? null Gets or sets a collection of additional attributes that will be applied to the created element.
Name string? null Gets or sets the name of the element. Allows access by name from the associated form.
NoValidate bool false Disables the validation of the input.
OnChange EventCallback<TValue?> Callback for when the input value changes.
ReadOnly bool false Makes the input read-only.
Required bool false Makes the input required.
Value TValue? null Gets or sets the value of the input. This should be used with two-way binding.

BitInputBase public members

Name Type Default value Description
InputElement ElementReference The ElementReference of the input element.
FocusAsync() () => ValueTask Gives focus to the input element.
FocusAsync(bool preventScroll) (bool preventScroll) => ValueTask Gives focus to the input element.

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.

BitRatingClassStyles properties

The CSS classes and styles of the individual parts of the BitRating.

Name Type Default value Description
Root string? null Custom CSS classes/styles for the root element of the rating.
LabelContainer string? null Custom CSS classes/styles for the container of the label of the rating.
Label string? null Custom CSS classes/styles for the label of the rating.
Description string? null Custom CSS classes/styles for the description of the rating.
Container string? null Custom CSS classes/styles for the container of the rating items.
Button string? null Custom CSS classes/styles for the button of each rating item, which is the pointer target that holds the glyphs and carries the data-is-current attribute marking the item the shown value lands in.
IconContainer string? null Custom CSS classes/styles for the rating icon container.
SelectedIcon string? null Custom CSS classes/styles for the rating selected icon.
UnselectedIcon string? null Custom CSS classes/styles for the rating unselected icon.

BitRatingChangeArgs properties

The arguments of the OnChanging callback, which runs before the value of the rating changes.

Name Type Default value Description
Value double The rating value the component is about to move to.
OldValue double The rating value the component is moving away from.
Cancel bool false Set to true to cancel the change and keep the current value of the rating.

BitRatingItemContext properties

The context passed to the ItemTemplate, describing the rating item being rendered.

Name Type Default value Description
Index int The one-based position of the item in the rating.
Max int The number of items the rating renders.
Percentage double How much of the item is filled, from 0 to 100. A partially filled item is the fractional part of the value.
DisplayValue double The value the item is rendered from, which is the hovered value while a hover preview is active, and the committed value otherwise.
Value double The committed value of the rating, regardless of any hover preview.
IsSelected bool Whether the item is filled at all, meaning its Percentage is greater than zero.
IsFull bool Whether the item is completely filled, meaning its Percentage is 100.
IsCurrent bool Whether this is the item the shown value lands in - the fourth of a 3.5, and the one under the pointer while a hover preview is running. It is the item being picked rather than the exact committed value.

BitIconInfo properties

Represents icon information for rendering icons. Supports built-in Fluent UI icons and external icon libraries (FontAwesome, Bootstrap Icons, etc.). Use BitIconInfo.Css("fa-solid fa-star"), BitIconInfo.Fa("solid star"), or BitIconInfo.Bi("star-fill") for external icons.

Name Type Default value Description
Name string? null Gets or sets the name of the icon.
BaseClass string? null Gets or sets the base CSS class for the icon. For external icon libraries like FontAwesome, you might set this to "fa" or leave empty.
Prefix string? null Gets or sets the CSS class prefix used before the icon name. For external icon libraries, you might set this to "fa-" or leave empty.

BitSize enum

Name Value Description
Small 0 Display rating icon using small size.
Medium 1 Display rating icon using medium size.
Large 2 Display rating icon using large size.

BitPlacement enum

Name Value Description
Top 0 The top edge.
Bottom 1 The bottom edge.
Start 2 The edge the reading direction starts from - the left in LTR, the right in RTL. On the vertical axis, which does not turn around, it is the top.
End 3 The edge the reading direction ends at - the right in LTR, the left in RTL. On the vertical axis, which does not turn around, it is the bottom.
Left 4 The left edge, in both reading directions.
Right 5 The right edge, in both reading directions.
Center 6 The middle of the axis, against neither edge.
TopAndBottom 7 Both edges of the block axis at once.
StartAndEnd 8 Both edges of the inline axis at once, following the reading direction the way Start and End do.

BitColor enum

Name Value Description
Primary 0 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.

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.