Skip to content

Inputs

TextField

Bit.BlazorUITextInputTextAreaPasswordField

Text fields give people a way to enter and edit text. They're used in forms, modal dialogs, tables, and other surfaces where text input is required. A single BitTextField renders either an input or a textarea, carries a label in any of the four positions around it, a visible or screen-reader-only description, a character counter and a message saying why the value was rejected, exposes every part of its chrome to templates and to the Styles and Classes parameters, wires its own labels and descriptions to the input through the aria attributes, and plugs into an EditForm the same way the built-in Blazor inputs do.

Customization

Defaults for every field of a subtree through BitParams, the background, border and accent colors, external icons, sizes, Style & Class with the CSS variables, and right-to-left fields.

Cascading parameters

BitParams carries a BitTextFieldParams down to every text field under it, so a form, a panel or a whole app sets the shared look and the shared input behavior once instead of on every field. What it carries is a default and not an override: a field that writes a parameter for itself keeps its own value, and only what it left unset is filled in from the cascade.

Three groups of parameters are deliberately not on the params object, because sharing them between fields would be wrong rather than merely unused: what identifies a field and carries its value (Value, DefaultValue, Name, DisplayName), the event callbacks, and what says something about the value in one field alone (Invalid, ErrorMessage, GhostText, Loading, AutoFocus). InputHtmlAttributes and NoValidate stay out too, as they do for every input: the first is a dictionary the field writes into, and the second is read before a cascade is applied.




Background

Background picks the fill of the field from the color kinds of the theme. Transparent is the one to use when the field sits on a colored surface and should inherit it instead of punching a light rectangle into it.




Border

Border picks the color of the frame from the same color kinds, independently of the background. Transparent keeps the border box - and therefore the layout - while making the line itself invisible, which is the difference between it and NoBorder. Each kind carries its own hover step, so the frame darkens under the pointer without leaving the kind it was given, and a Transparent one stays invisible. The hover is drawn on pointer devices only, and never over a focused or a rejected frame.




Accent

Accent is the color the field takes on while it has focus: the focus ring, the icon and the affixes all follow it. Primary is the default, and the remaining variants are what gives a field a meaning of its own - a success green on a confirmed value, an error red on a rejected one - without touching the rest of the theme.

















External Icons

The Icon parameter takes a BitIconInfo instead of a built-in icon name, which is what lets an icon come from FontAwesome, Bootstrap Icons or any other icon font: BitIconInfo.Fa and BitIconInfo.Bi build the class names of those two libraries, BitIconInfo.Css takes the classes verbatim, and a plain string is implicitly converted to one. The same applies to ClearButtonIcon, RevealPasswordIcon and HidePasswordIcon.


FontAwesome:







Bootstrap:




Size

Size scales the whole field at once - its height, its font, its icons and its buttons - so a field stays proportional to the controls next to it. Medium is the default; Small is what a dense toolbar or a table row wants, and Large is what a landing page form wants.





Style & Class

Style and Class land on the root element, while Styles and Classes reach every inner part by name - the label, the field group, the input, the buttons, the footer and the counter - which is what makes a fully custom look possible without overriding the stylesheet. Focused is applied to the root only while the field has focus, so a floating label can be driven entirely from these two parameters.

For the look rather than the layout there are the public --bit-TextField-* custom properties listed in the CSS variables table. They are read off the element and inherited, so the same name set on :root re-skins every field of the app, set on an ancestor re-skins the fields inside it, and set on the Style of one field re-skins that one and any field nested in it - without a selector, a scoped stylesheet or a ::deep anywhere. Anything left unset keeps the value the theme gives it, so a single property can be swapped without restating the rest. They restyle the default, not a choice: an explicit Accent, Background, Border or Size wins over the variables for what it sets.


CSS variables:



0/20


Component's Style & Class:





Styles & Classes:


RTL

Set Dir="BitDir.Rtl" to mirror the field for a right-to-left language. The label, the affixes, the buttons, the required asterisk and the underline all follow the direction, since the layout is written with logical properties rather than left and right ones.





3/20

Feedback

Found a mistake, a gap, or something that could be clearer? Every page and every component is one click from its source.