Class MudBaseInput<T>
- Namespace
- MudBlazor
- Assembly
- MudBlazor.dll
Represents a base class for designing form input components.
public abstract class MudBaseInput<T> : MudFormComponent<T, string>, IComponent, IHandleEvent, IHandleAfterRender, IMudStateHasChanged, IFormComponent, IAsyncDisposable
Type Parameters
T
The type of item being input.
- Inheritance
-
MudBaseInput<T>
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
MudBaseInput()
protected MudBaseInput()
Fields
_forceTextUpdate
protected bool _forceTextUpdate
Field Value
_isFocused
protected bool _isFocused
Field Value
Properties
Adornment
The location of the adornment icon or text.
[Parameter]
[Category("Behavior")]
public Adornment Adornment { get; set; }
Property Value
Remarks
Defaults to None. When set to Start
or End
, the AdornmentText will be displayed, or AdornmentIcon if no adornment text is specified.
AdornmentAriaLabel
The aria-label
for the adornment.
[Parameter]
[Category("Appearance")]
public string? AdornmentAriaLabel { get; set; }
Property Value
Remarks
Defaults to null
.
AdornmentColor
The color of AdornmentText or AdornmentIcon.
[Parameter]
[Category("Appearance")]
public Color AdornmentColor { get; set; }
Property Value
Remarks
Defaults to Default. Theme colors are supported.
AdornmentIcon
The icon displayed for the adornment.
[Parameter]
[Category("Behavior")]
public string? AdornmentIcon { get; set; }
Property Value
Remarks
Defaults to null
. This icon will be displayed when Adornment is Start
or End
, and no value for AdornmentText is set.
AdornmentText
The text displayed for the adornment.
[Parameter]
[Category("Behavior")]
public string? AdornmentText { get; set; }
Property Value
Remarks
Defaults to null
. This text will be displayed when Adornment is Start
or End
. The AdornmentIcon property will be ignored if this property is set.
AutoFocus
Automatically receives focus.
[Parameter]
[Category("Behavior")]
public bool AutoFocus { get; set; }
Property Value
Remarks
Defaults to false
. When true
, the input will receive focus automatically.
Counter
The optional character count and stop count.
[Parameter]
[Category("Validation")]
public int? Counter { get; set; }
Property Value
- int?
Remarks
Defaults to null
. When 0
, the current character count is displayed. When 1
or greater, the character count and this count are displayed.
Disabled
Allows the component to receive input.
[Parameter]
[Category("Behavior")]
public bool Disabled { get; set; }
Property Value
Remarks
Defaults to false
.
Format
The format applied to values.
[Parameter]
[Category("Behavior")]
public string? Format { get; set; }
Property Value
Remarks
This property is passed into the ToString()
method of the Value property, such as formatting int
, float
, DateTime
and TimeSpan
values.
FullWidth
Fills the full width of the parent container.
[Parameter]
[Category("Appearance")]
public bool FullWidth { get; set; }
Property Value
Remarks
Defaults to false
.
HelperId
The ID of the helper element, for use by aria-describedby
.
[Parameter]
[Category("Validation")]
public string? HelperId { get; set; }
Property Value
Remarks
Defaults to null
. When set it is appended to the aria-describedby
attribute to improve accessibility for users. This ID takes precedence over the helper element rendered when HelperText is provided.
HelperText
The text displayed below the text field.
[Parameter]
[Category("Behavior")]
public string? HelperText { get; set; }
Property Value
Remarks
This property is typically used to help the user understand what kind of input is allowed. The HelperTextOnFocus property controls when this text is visible.
HelperTextOnFocus
Displays the HelperText only when this input has focus.
[Parameter]
[Category("Behavior")]
public bool HelperTextOnFocus { get; set; }
Property Value
Remarks
Defaults to false
.
IconSize
The size of the icon.
[Parameter]
[Category("Appearance")]
public Size IconSize { get; set; }
Property Value
Remarks
Defaults to Medium.
Immediate
Changes the Value as soon as input is received.
[Parameter]
[Category("Behavior")]
public bool Immediate { get; set; }
Property Value
Remarks
Defaults to false
. When true
, the Value property will be updated any time user input occurs. Otherwise, Value is updated when the user presses Enter
or the input loses focus.
InputElementId
The resolved input element ID.
protected string? InputElementId { get; }
Property Value
InputId
The ID of the input element.
[Parameter]
[Category("Behavior")]
public string? InputId { get; set; }
Property Value
Remarks
When set takes precedence over any internally generated IDs.
InputMode
The type of input expected.
[Parameter]
[Category("Behavior")]
public virtual InputMode InputMode { get; set; }
Property Value
Remarks
Defaults to text.
KeyDownPreventDefault
Allows the default key-down action to occur.
[Parameter]
[Category("Behavior")]
public bool KeyDownPreventDefault { get; set; }
Property Value
Remarks
When true
, the browser will not perform its default behavior when a key-down occurs. This is typically used when a key-down needs to override a browser's default behavior.
KeyUpPreventDefault
Prevents the default key-up action.
[Parameter]
[Category("Behavior")]
public bool KeyUpPreventDefault { get; set; }
Property Value
Remarks
When true
, the browser will not perform its default behavior when a key-up occurs. This is typically used when a key-up needs to override the browser's default behavior.
Label
The label for this input.
[Parameter]
[Category("Behavior")]
public string? Label { get; set; }
Property Value
Remarks
If no Value is specified, the label will be displayed in the input. Otherwise, it will be scaled down to the top of the input.
Lines
A multiline input (textarea) will be shown, if set to more than one line.
[Parameter]
[Category("Behavior")]
public int Lines { get; set; }
Property Value
Margin
The amount of vertical spacing for this input.
[Parameter]
[Category("Appearance")]
public Margin Margin { get; set; }
Property Value
Remarks
MaxLength
The maximum number of characters allowed.
[Parameter]
[Category("Validation")]
public int MaxLength { get; set; }
Property Value
Remarks
Defaults to 524288
. This value is typically set to a maximum length such as the size of a database column the value will be persisted to.
OnAdornmentClick
Occurs when the adornment text or icon has been clicked.
[Parameter]
public EventCallback<MouseEventArgs> OnAdornmentClick { get; set; }
Property Value
OnBlur
Occurs when the input loses focus.
[Parameter]
public EventCallback<FocusEventArgs> OnBlur { get; set; }
Property Value
OnInternalInputChanged
Occurs when the internal text value has changed.
[Parameter]
public EventCallback<ChangeEventArgs> OnInternalInputChanged { get; set; }
Property Value
OnKeyDown
Occurs when a key has been pressed down.
[Parameter]
public EventCallback<KeyboardEventArgs> OnKeyDown { get; set; }
Property Value
OnKeyUp
Occurs when a pressed key has been released.
[Parameter]
public EventCallback<KeyboardEventArgs> OnKeyUp { get; set; }
Property Value
OnlyValidateIfDirty
Limits validation to when the user changes the Value.
[Parameter]
[Category("Behavior")]
public bool OnlyValidateIfDirty { get; set; }
Property Value
Remarks
Defaults to false
. When true
, validation only occurs if the user has changed the input value at least once.
Pattern
The regular expression used to validate the Value property.
[Parameter]
[Category("Validation")]
public virtual string? Pattern { get; set; }
Property Value
Remarks
Defaults to null
. This property is used to validate the input against a regular expression. Not supported if Lines is 2
or greater. Must be a valid JavaScript regular expression.
Placeholder
The text displayed in the input if no Value is specified.
[Parameter]
[Category("Behavior")]
public string? Placeholder { get; set; }
Property Value
Remarks
This property is typically used to give the user a hint as to what kind of input is expected.
ReadOnly
Prevents the input from being changed by the user.
[Parameter]
[Category("Behavior")]
public bool ReadOnly { get; set; }
Property Value
Remarks
Defaults to false
. When true
, the user can copy text in the control, but cannot change the Value.
ShrinkLabel
Shows the label inside the input if no Value is specified.
[Parameter]
[Category("Appearance")]
public bool ShrinkLabel { get; set; }
Property Value
Remarks
Defaults to false
in ShrinkLabel.
When true
, the label will not move into the input when the input is empty.
Text
The text displayed in the input.
[Parameter]
[Category("Data")]
public string? Text { get; set; }
Property Value
TextChanged
Occurs when the Text property has changed.
[Parameter]
public EventCallback<string> TextChanged { get; set; }
Property Value
TextUpdateSuppression
Prevents the text from being updated via a bound value.
[Parameter]
[Category("Behavior")]
public bool TextUpdateSuppression { get; set; }
Property Value
Remarks
Defaults to true
. Applies only to Blazor Server (BSS) applications. When false
, the input's text can be updated programmatically while the input has focus.
Typo
Typography for the input text.
[Parameter]
[Category("Appearance")]
public Typo Typo { get; set; }
Property Value
Underline
Displays an underline for the input.
[Parameter]
[Category("Appearance")]
public bool Underline { get; set; }
Property Value
Remarks
Defaults to true
.
Value
The value for this input.
[Parameter]
[Category("Data")]
public T? Value { get; set; }
Property Value
- T
Remarks
This property represents the strongly typed value for the input. It is typically the result of parsing raw input via the Text property.
ValueChanged
Occurs when the Value property has changed.
[Parameter]
public EventCallback<T> ValueChanged { get; set; }
Property Value
Variant
The appearance variation to use.
[Parameter]
[Category("Appearance")]
public Variant Variant { get; set; }
Property Value
Remarks
Methods
BlurAsync()
When overridden, releases focus from this input.
public virtual ValueTask BlurAsync()
Returns
FocusAsync()
When overridden, obtains focus for this input.
public virtual ValueTask FocusAsync()
Returns
ForceRender(bool)
Causes this input to be rerendered.
public virtual void ForceRender(bool forceTextUpdate)
Parameters
ForceUpdate()
Sets the value, values, and text, and calls validation.
public virtual Task ForceUpdate()
Returns
Remarks
GetAriaDescribedByString()
protected string? GetAriaDescribedByString()
Returns
GetDisabledState()
protected bool GetDisabledState()
Returns
GetHelperId()
protected string? GetHelperId()
Returns
GetReadOnlyState()
protected bool GetReadOnlyState()
Returns
InvokeKeyDownAsync(KeyboardEventArgs)
protected virtual Task InvokeKeyDownAsync(KeyboardEventArgs obj)
Parameters
Returns
InvokeKeyUpAsync(KeyboardEventArgs)
protected virtual Task InvokeKeyUpAsync(KeyboardEventArgs obj)
Parameters
Returns
OnAfterRenderAsync(bool)
protected override Task OnAfterRenderAsync(bool firstRender)
Parameters
firstRender
bool
Returns
OnBlurredAsync(FocusEventArgs)
protected virtual Task OnBlurredAsync(FocusEventArgs obj)
Parameters
obj
FocusEventArgs
Returns
OnInitializedAsync()
protected override Task OnInitializedAsync()
Returns
OnParametersSet()
protected override void OnParametersSet()
ResetValueAsync()
protected override Task ResetValueAsync()
Returns
SelectAsync()
When overridden, selects this input.
public virtual ValueTask SelectAsync()
Returns
SelectRangeAsync(int, int)
When overridden, selects a portion of the input.
public virtual ValueTask SelectRangeAsync(int pos1, int pos2)
Parameters
pos1
intThe index of the first character to select.
pos2
intThe index of the last character to select.
Returns
SetConverter(Converter<T, string>)
protected override bool SetConverter(Converter<T, string> value)
Parameters
Returns
SetCulture(CultureInfo)
protected override bool SetCulture(CultureInfo value)
Parameters
value
CultureInfo
Returns
SetFormat(string?)
protected virtual bool SetFormat(string? value)
Parameters
value
string
Returns
SetParametersAsync(ParameterView)
public override Task SetParametersAsync(ParameterView parameters)
Parameters
parameters
ParameterView
Returns
SetTextAsync(string?, bool)
protected virtual Task SetTextAsync(string? text, bool updateValue = true)
Parameters
Returns
SetValueAsync(T?, bool, bool)
protected virtual Task SetValueAsync(T? value, bool updateText = true, bool force = false)
Parameters
Returns
UpdateTextPropertyAsync(bool)
Occurs when the value has changed internally.
protected virtual Task UpdateTextPropertyAsync(bool updateValue)
Parameters
updateValue
bool
Returns
Remarks
UpdateValuePropertyAsync(bool)
Occurs when the value has changed internally.
protected virtual Task UpdateValuePropertyAsync(bool updateText)
Parameters
updateText
bool
Returns
Remarks
ValidateValue()
protected override Task ValidateValue()