Layout
TwMenu
TwMenu is a Blazor menu button component that opens a keyboard friendly menu of actions, tick options and labelled groups.
Last updated
Please be aware this component is new, may have bugs and/or be subject to change. Please report any bugs at
https://github.com/twblazor/twblazor/issues.
Options that can be ticked
A
TwMenuCheckboxItem is an option that is on or off. Bind @bind-Checked. Choosing it flips the tick and leaves the menu open, so several options can be changed in a row; set CloseOnClick to close it instead. Screen readers announce each option as ticked or not.
Grid on, rulers off, snapping off.
Groups and dividers
Use
TwMenuGroup to put items under a heading, which screen readers read as the group's name, and TwMenuDivider for a line between items. The arrow keys pass over both. A Disabled item is skipped and cannot be chosen.RAZOR
<TwMenu Id="group-menu" Label="Column options" Icon="Icon.Layout_Three_Columns">
<TwMenuGroup Label="Sort">
<TwMenuItem Label="Sort ascending" StartIcon="Icon.Sort_Up" />
<TwMenuItem Label="Sort descending" StartIcon="Icon.Sort_Down" />
</TwMenuGroup>
<TwMenuDivider />
<TwMenuGroup Label="Column">
<TwMenuItem Label="Move left" StartIcon="Icon.Arrow_Left" Disabled />
<TwMenuItem Label="Move right" StartIcon="Icon.Arrow_Right" />
<TwMenuItem Label="Hide column" StartIcon="Icon.Eye_Slash" />
</TwMenuGroup>
</TwMenu>Inside a scrolling container
The menu is placed with fixed positioning, so it is not clipped by a container that scrolls, such as a table, and it flips above its button or towards the start when there is no room. Scrolling the page closes it on desktop.
| File | Actions |
|---|---|
| report.pdf | |
| budget.xlsx | |
| notes.txt | |
| logo.svg |
Theme configuration
Styling is controlled by
TwBlazorTheme.Components (a TwMenuTheme), configured via the
AddTwBlazor() options callback described on the Get Started page.
Every property is a set of Tailwind classes, so changes are picked up by your own Tailwind build.
| Property | Type | Controls |
|---|---|---|
Root |
string | |
Panel |
string | |
Item |
string | |
ItemDisabled |
string | |
ItemIcon |
string | |
CheckIcon |
string | |
CheckIconHidden |
string | |
Divider |
string | |
GroupLabel |
string |
Full reference: TwMenuTheme on the API docs.