Table of Contents

Class MudToggleGroup<T>

Namespace
MudBlazor
Assembly
MudBlazor.dll

Maintains the selection of a group of MudToggleItem<T> components.

[CascadingTypeParameter("T")]
public class MudToggleGroup<T> : MudComponentBase, IComponent, IHandleEvent, IHandleAfterRender, IMudStateHasChanged

Type Parameters

T

The type of item being toggled.

Inheritance
MudToggleGroup<T>
Implements
Inherited Members
Extension Methods

Constructors

MudToggleGroup()

public MudToggleGroup()

Properties

CheckMark

Shows a checkmark next to each item.

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

Property Value

bool

Remarks

Defaults to false. When true, the checkmark icons can be customized via SelectedIcon and UnselectedIcon.

CheckMarkClass

The CSS classes applied to checkmark icons.

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

Property Value

string

Remarks

Defaults to null.
Applies when CheckMark is true. Classes are applied to the SelectedIcon and UnselectedIcon icons.
Multiple classes must be separated by spaces.

ChildContent

Contains the MudToggleItem<T> components of this group.

[Parameter]
[Category("Behavior")]
public RenderFragment? ChildContent { get; set; }

Property Value

RenderFragment

Classname

protected string Classname { get; }

Property Value

string

Color

The color of borders and the current selections.

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

Property Value

Color

Remarks

Defaults to Primary.

Delimiters

Shows a line delimiter between each item.

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

Property Value

bool

Remarks

Defaults to true.

Disabled

Prevents the user from interacting with this toggle group.

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

Property Value

bool

FixedContent

Reserves space for checkmarks even when CheckMark is false.

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

Property Value

bool

Remarks

Defaults to false.

Outlined

Shows an outline border.

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

Property Value

bool

Remarks

Defaults to true.

RightToLeft

[CascadingParameter(Name = "RightToLeft")]
public bool RightToLeft { get; set; }

Property Value

bool

Ripple

Show a ripple effect when the user clicks an item.

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

Property Value

bool

Remarks

Defaults to true.

SelectedClass

The CSS classes applied to selected items.

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

Property Value

string

Remarks

Defaults to null. Multiple classes must be separated by spaces.

SelectionMode

The selection behavior for this group.

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

Property Value

SelectionMode

Remarks

Defaults to SingleSelection.

  • SingleSelection: Allows only one item to be selected at a time.
  • MultiSelection: Allows multiple items to be selected.
  • ToggleSelection: Allows only one item to be selected, but the current selection can be deselected.

Size

The size of each toggle item.

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

Property Value

Size

Remarks

Defaults to Medium.

Stylename

protected string Stylename { get; }

Property Value

string

Value

The currently selected value.

[Parameter]
[Category("Behavior")]
public T? Value { get; set; }

Property Value

T

Remarks

ValueChanged

Occurs when Value has changed.

[Parameter]
[Category("Behavior")]
public EventCallback<T?> ValueChanged { get; set; }

Property Value

EventCallback<T>

Remarks

Values

The currently selected values.

[Parameter]
[Category("Behavior")]
public IEnumerable<T?>? Values { get; set; }

Property Value

IEnumerable<T>

Remarks

Applies when SelectionMode is MultiSelection.

ValuesChanged

Occurs when Values has changed.

[Parameter]
[Category("Behavior")]
public EventCallback<IEnumerable<T?>?> ValuesChanged { get; set; }

Property Value

EventCallback<IEnumerable<T>>

Remarks

Applies when SelectionMode is MultiSelection.

Vertical

Uses a vertical layout for items.

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

Property Value

bool

Remarks

Defaults to false.

Methods

BuildRenderTree(RenderTreeBuilder)

protected override void BuildRenderTree(RenderTreeBuilder __builder)

Parameters

__builder RenderTreeBuilder

GetItems()

protected IEnumerable<MudToggleItem<T>> GetItems()

Returns

IEnumerable<MudToggleItem<T>>

IsFirstItem(MudToggleItem<T>)

protected bool IsFirstItem(MudToggleItem<T> item)

Parameters

item MudToggleItem<T>

Returns

bool

IsLastItem(MudToggleItem<T>)

protected bool IsLastItem(MudToggleItem<T> item)

Parameters

item MudToggleItem<T>

Returns

bool

OnInitialized()

protected override void OnInitialized()

Register(MudToggleItem<T>)

Adds the specified item to this group.

protected void Register(MudToggleItem<T> item)

Parameters

item MudToggleItem<T>

The item to add.

ToggleItemAsync(MudToggleItem<T>)

protected Task ToggleItemAsync(MudToggleItem<T> item)

Parameters

item MudToggleItem<T>

Returns

Task

Unregister(MudToggleItem<T>)

Removes the specified item from this group.

protected void Unregister(MudToggleItem<T> item)

Parameters

item MudToggleItem<T>

The item to remove.

See Also