Table of Contents

Class MudPicker<T>

Namespace
MudBlazor
Assembly
MudBlazor.dll

A component for selecting date, time, and color values.

public class MudPicker<T> : MudFormComponent<T, string>, IComponent, IHandleEvent, IHandleAfterRender, IMudStateHasChanged, IFormComponent, IAsyncDisposable

Type Parameters

T

The type of value being chosen.

Inheritance
MudPicker<T>
Implements
Derived
Inherited Members
Extension Methods

Constructors

MudPicker()

public MudPicker()

MudPicker(Converter<T, string>)

protected MudPicker(Converter<T, string> converter)

Parameters

converter Converter<T, string>

Fields

_inputReference

protected MudTextField<string>? _inputReference

Field Value

MudTextField<string>

_mask

protected IMask? _mask

Field Value

IMask

Properties

ActionsClass

The CSS classes applied to the action buttons container.

[Parameter]
[Category("Picker appearance")]
public string? ActionsClass { get; set; }

Property Value

string

Remarks

Multiple classes must be separated by a space.

ActionsClassname

protected string ActionsClassname { get; }

Property Value

string

Adornment

The location of the AdornmentIcon for the input.

[Parameter]
[Category("Behavior")]
public Adornment Adornment { get; set; }

Property Value

Adornment

Remarks

Defaults to End.

AdornmentAriaLabel

The aria-label for the adornment.

[Parameter]
[Category("Appearance")]
public string? AdornmentAriaLabel { get; set; }

Property Value

string

Remarks

Defaults to null.

AdornmentColor

The color of the AdornmentIcon.

[Parameter]
[Category("Appearance")]
public Color AdornmentColor { get; set; }

Property Value

Color

Remarks

Defaults to Default.

AdornmentIcon

The icon shown next to the text input.

[Parameter]
[Category("Behavior")]
public string AdornmentIcon { get; set; }

Property Value

string

Remarks

Defaults to Event.

AnchorOrigin

The location the popover opens, relative to its container.

[Parameter]
[Category("Appearance")]
public Origin AnchorOrigin { get; set; }

Property Value

Origin

Remarks

Defaults to BottomLeft.

Clearable

Displays the Clear icon button.

[Parameter]
[Category("Behavior")]
public bool Clearable { get; set; }

Property Value

bool

Remarks

Defaults to false.
When true, an icon is displayed which, when clicked, clears the Text and Value. Use the ClearIcon property to control the Clear button icon.

Color

The color of the toolbar, selected, and active values.

[Parameter]
[Category("Picker appearance")]
public Color Color { get; set; }

Property Value

Color

Remarks

Defaults to Primary.

Disabled

Prevents the user from interacting with this button.

[Parameter]
[Category("Behavior")]
public bool Disabled { get; set; }

Property Value

bool

Remarks

Defaults to false.

Editable

Allows the value to be edited.

[Parameter]
[Category("Behavior")]
public bool Editable { get; set; }

Property Value

bool

Remarks

Defaults to false.

Elevation

The size of the drop shadow.

[Parameter]
[Category("Picker appearance")]
public int? Elevation { get; set; }

Property Value

int?

Remarks

Defaults to 8 for inline pickers; otherwise 0.
A higher number creates a heavier drop shadow. Use a value of 0 for no shadow.

HelperText

The text displayed below the text field.

[Parameter]
[Category("Behavior")]
public string? HelperText { get; set; }

Property Value

string

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

bool

Remarks

Defaults to false.

IconSize

The size of the icon in the input field.

[Parameter]
[Category("Appearance")]
public Size IconSize { get; set; }

Property Value

Size

Remarks

Defaults to Medium.

ImmediateText

Updates Text immediately upon typing when Editable is true.

[Parameter]
[Category("Behavior")]
public bool ImmediateText { get; set; }

Property Value

bool

Remarks

Defaults to false.
When false, Text is only updated when pressing Enter or upon loss of focus.

InputContent

protected virtual RenderFragment? InputContent { get; }

Property Value

RenderFragment

Label

The label for this input.

[Parameter]
[Category("Behavior")]
public string? Label { get; set; }

Property Value

string

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.

Margin

Applies vertical spacing.

[Parameter]
[Category("Appearance")]
public Margin Margin { get; set; }

Property Value

Margin

Mask

The mask to apply to input values when Editable is true.

[Parameter]
[Category("Behavior")]
public IMask? Mask { get; set; }

Property Value

IMask

OnClick

Occurs when the text input has been clicked.

[Parameter]
public EventCallback<MouseEventArgs> OnClick { get; set; }

Property Value

EventCallback<MouseEventArgs>

Open

protected bool Open { get; set; }

Property Value

bool

Orientation

The orientation of the picker when PickerVariant is Static.

[Parameter]
[Category("Picker appearance")]
public Orientation Orientation { get; set; }

Property Value

Orientation

Remarks

Defaults to Portrait.

OverflowBehavior

The behavior of the popover when it overflows its container.

[Parameter]
[Category("Appearance")]
public OverflowBehavior OverflowBehavior { get; set; }

Property Value

OverflowBehavior

Remarks

Defaults to FlipOnOpen.

PickerActions

The custom action buttons to display.

[Parameter]
[Category("Picker behavior")]
public RenderFragment<MudPicker<T>>? PickerActions { get; set; }

Property Value

RenderFragment<MudPicker<T>>

PickerClassname

protected string PickerClassname { get; }

Property Value

string

PickerClosed

Occurs when this picker has closed.

[Parameter]
public EventCallback PickerClosed { get; set; }

Property Value

EventCallback

PickerContainerClassname

protected string PickerContainerClassname { get; }

Property Value

string

PickerContent

Gets the content to be rendered inside the picker. Override this property to provide custom content for the picker.

protected virtual RenderFragment? PickerContent { get; }

Property Value

RenderFragment

PickerInlineClassname

protected string PickerInlineClassname { get; }

Property Value

string

PickerInputClassname

protected string PickerInputClassname { get; }

Property Value

string

PickerOpened

Occurs when this picker has opened.

[Parameter]
public EventCallback PickerOpened { get; set; }

Property Value

EventCallback

PickerPaperClassname

protected string PickerPaperClassname { get; }

Property Value

string

PickerPaperStylename

protected string PickerPaperStylename { get; }

Property Value

string

PickerVariant

The display variant for this picker.

[Parameter]
[Category("Behavior")]
public PickerVariant PickerVariant { get; set; }

Property Value

PickerVariant

Remarks

Defaults to Inline.
Other values are Dialog and Static.

Placeholder

The text displayed in the input if no value is specified.

[Parameter]
[Category("Behavior")]
public string? Placeholder { get; set; }

Property Value

string

Remarks

This property is typically used to give the user a hint as to what kind of input is expected.

PopoverClassname

protected string PopoverClassname { get; }

Property Value

string

ReadOnly

Prevents the input from being changed by the user.

[Parameter]
[Category("Behavior")]
public bool ReadOnly { get; set; }

Property Value

bool

Remarks

Defaults to false.
When true, the user can copy text in the control, but cannot change the value.

RelativeWidth

Determines the width of the Popover dropdown in relation the parent container.

[Parameter]
[Category("Appearance")]
public DropdownWidth RelativeWidth { get; set; }

Property Value

DropdownWidth

Remarks

Defaults to Ignore.

When Relative, restricts the max-width of the component to the width of the parent container

When Adaptive, restricts the min-width of the component to the width of the parent container

Render

protected virtual RenderFragment? Render { get; }

Property Value

RenderFragment

Rounded

Shows rounded corners.

[Parameter]
[Category("Picker appearance")]
public bool Rounded { get; set; }

Property Value

bool

Remarks

Defaults to false. Can be overridden by Rounded. When true, the border-radius style is set to the theme's default value.

ShowToolbar

Shows the toolbar.

[Parameter]
[Category("Picker appearance")]
public bool ShowToolbar { get; set; }

Property Value

bool

Remarks

Defaults to true.

Square

Disables rounded corners.

[Parameter]
[Category("Picker appearance")]
public bool Square { get; set; }

Property Value

bool

Remarks

Defaults to false. Can be overridden by Rounded.

Text

The currently selected value, as a string.

[Parameter]
[Category("Data")]
public string? Text { get; set; }

Property Value

string

TextChanged

Occurs when Text has changed.

[Parameter]
public EventCallback<string> TextChanged { get; set; }

Property Value

EventCallback<string>

ToolbarClass

The CSS classes for the toolbar when ShowToolbar is true.

[Parameter]
[Category("Picker appearance")]
public string? ToolbarClass { get; set; }

Property Value

string

Remarks

Multiple classes must be separated by spaces.

TransformOrigin

The direction the popover opens, relative to its container.

[Parameter]
[Category("Appearance")]
public Origin TransformOrigin { get; set; }

Property Value

Origin

Remarks

Defaults to TopLeft.

Underline

Shows an underline under the input text.

[Parameter]
[Category("Appearance")]
public bool Underline { get; set; }

Property Value

bool

Remarks

Defaults to true.

Variant

The display variant of the text input.

[Parameter]
[Category("Appearance")]
public Variant Variant { get; set; }

Property Value

Variant

Remarks

Defaults to Text.

Methods

BlurAsync()

Releases focus for the input.

public virtual ValueTask BlurAsync()

Returns

ValueTask

BuildRenderTree(RenderTreeBuilder)

protected override void BuildRenderTree(RenderTreeBuilder __builder)

Parameters

__builder RenderTreeBuilder

ClearAsync(bool)

Hides this picker.

public virtual Task ClearAsync(bool close = true)

Parameters

close bool

When true, the picker will be closed if PickerVariant is not Static.

Returns

Task

CloseAsync(bool)

Closes this picker.

public Task CloseAsync(bool submit = true)

Parameters

submit bool

When true, the value is committed.

Returns

Task

DisposeAsyncCore()

Called to dispose this instance.

protected override ValueTask DisposeAsyncCore()

Returns

ValueTask

FocusAsync()

Focuses the input.

public virtual ValueTask FocusAsync()

Returns

ValueTask

GetDisabledState()

protected bool GetDisabledState()

Returns

bool

GetReadOnlyState()

protected bool GetReadOnlyState()

Returns

bool

OnAfterRenderAsync(bool)

protected override Task OnAfterRenderAsync(bool firstRender)

Parameters

firstRender bool

Returns

Task

OnClosedAsync()

protected virtual Task OnClosedAsync()

Returns

Task

OnHandleKeyDownAsync(KeyboardEventArgs)

protected virtual Task OnHandleKeyDownAsync(KeyboardEventArgs args)

Parameters

args KeyboardEventArgs

Returns

Task

OnInitialized()

protected override void OnInitialized()

OnOpenedAsync()

protected virtual Task OnOpenedAsync()

Returns

Task

OnPickerClosedAsync()

protected virtual Task OnPickerClosedAsync()

Returns

Task

OnPickerOpenedAsync()

protected virtual Task OnPickerOpenedAsync()

Returns

Task

OpenAsync()

Displays this picker.

public Task OpenAsync()

Returns

Task

ResetValueAsync()

protected override Task ResetValueAsync()

Returns

Task

SelectAsync()

Selects the input content.

public virtual ValueTask SelectAsync()

Returns

ValueTask

SelectRangeAsync(int, int)

Selects a portion of the input content.

public virtual ValueTask SelectRangeAsync(int pos1, int pos2)

Parameters

pos1 int

The index of the first character to select.

pos2 int

The index of the last character to select.

Returns

ValueTask

SetTextAsync(string?, bool)

protected Task SetTextAsync(string? value, bool callback)

Parameters

value string
callback bool

Returns

Task

StringValueChangedAsync(string?)

Occurs when the string value has changed.

protected virtual Task StringValueChangedAsync(string? value)

Parameters

value string

Returns

Task

SubmitAsync()

protected virtual Task SubmitAsync()

Returns

Task

ToggleOpenAsync()

Opens or closes this picker.

public Task ToggleOpenAsync()

Returns

Task

ToggleStateAsync()

protected Task ToggleStateAsync()

Returns

Task

See Also