'Requirement is onhover checkbox must be visible but onmouseout checked checkbox must be visible and unchecked checkbox must be invisible.My problem is Checkbox hovering function alone works but checked Checkbox on mouseout disappears'
.custom-nav-link .mud-checkbox {
display: none;
position: absolute;
top: 0;
left: 130px;
}
.custom-nav-link:hover .mud-checkbox {
display: inline-block;
}
.mud-checkbox:checked {
display: inline-block;
}
<div class="d-flex align-items-center custom-nav-link">
<MudNavLink Href="/dashboard" IconColor="Color.Secondary" Icon="@Icons.Material.Filled.Dashboard">My Dashboard </MudNavLink>
<MudCheckBox @bind-Checked="@isdashboardChecked" class="mud-checkbox" Color="Color.Primary" CheckedIcon="@Icons.Material.Filled.Star" UncheckedIcon="@Icons.Material.Filled.StarOutline" Size="Size.Small"></MudCheckBox>
</div>
MudCheckBoxis a component not an element i.e. it is a combination of one or more HTML elements, that's why you cannot use the:checkedpseudo class selector on it.displayHere's what you can do instead, use the
isdashboardCheckedbool field assigned to theCheckedproperty to add conditional classes instead.MudBlazor Snippet
visibilityYou can use
visibilityCSS property instead ofdisplay. With this, the checkbox wont displace other elements when it is visible/hidden.For example
MudBlazor Snippet