Buttons

ButtonControl

One native button, styled through CSS variables, with an optional dropdown.

Overview

ButtonControl renders one <button>. Variants are CSS classes, colors come from --fx-btn-* variables, and any attribute it does not recognise is forwarded to the element. Give it DropDownContent and it becomes a popup trigger that closes on click-away without JavaScript.

Examples

#Variants, icons and sizes

The default look comes from the theme variables; add one btn-* class for a semantic color. IconCss renders a leading icon, a trailing icon is ordinary content, and btn-sm / btn-lg change the size. Icon-only buttons need Title and aria-label. RoundedButtonControl is a pill-shaped subclass with four Variant colors. The CSS tab shows how a region is rethemed through --fx-btn-*.

Example
Razor
CSS

Documentation

Parameters

ParameterTypeDefaultDescription
ChildContentRenderFragment?—Button label or any markup.
CssClassstring?nullAppended after fx-button. Variant and size classes go here.
IconCssstring?nullClass list for a leading icon span. Any icon font works.
DisabledboolfalseSets the native disabled attribute; hover and active styles are suppressed.
OnClickEventCallback<MouseEventArgs>—Click handler. In dropdown mode it fires before the panel toggles.
ButtonTypestring"button"Native type: button, submit or reset.
Titlestring?nullNative tooltip. Required on icon-only buttons.
Stylestring?nullInline style. Useful for per-button CSS variables.
TabIndexint?nullNative tabindex.
AutoFocusboolfalseFocuses the button once after first render, unless disabled.
BareStyleboolfalseOmits the fx-button base class so host CSS owns the look.
StopPropagationboolfalseStops the click bubbling to ancestors that also handle clicks.
PreventMouseDownDefaultboolfalseKeeps focus where it was on mousedown. For editor formatting buttons.
DropDownContentRenderFragment?nullWhen set, the button toggles a popup panel beneath itself.
DropDownCssClassstring?nullExtra class on the popup panel.
(unmatched attributes)Dictionary<string,object>—Forwarded to the button: id, name, form, accesskey, aria-*, data-*. Explicit parameters win.
RoundedButtonControl.Variantstring"muted"Pill subclass only: accent, muted, success or danger.

Methods

MethodInputsReturnsDescription
FocusAsync()—ValueTaskFocuses the element without scrolling. Capture the component with @ref.
CloseDropDown()—voidCloses the popup, for example after a menu item is picked.

CSS classes

ClassEffect
btn-primary · btn-secondary · btn-success · btn-warning · btn-dangerFilled semantic colors.
btn-outline-primaryTransparent fill, blue border and text; fills on hover.
btn-sm · btn-lgCompact and large padding and font size.
fx-button-classicWin32 3D bevel, MS Sans Serif, square corners. For migrated VB6 forms.
mini-btn · fx-dialog-btnCompact grid-cell button; dialog footer padding.

CSS variables

VariableFallbackPurpose
--fx-btn-bg / --fx-btn-color#f7f7f7 / #333Resting fill and text.
--fx-btn-border / --fx-btn-border-color1px solid #c9c9c9Border shorthand and per-side color (Win32 bevel).
--fx-btn-radius4pxCorner radius.
--fx-btn-hover-bg / --fx-btn-hover-border#e6e6e6 / the --fx-btn-border valueHover state.
--fx-btn-active-bg#b6b6b6Pressed state.
--fx-btn-shadownoneBox shadow.
--fx-font-size × --fx-zoom13px × 1Font size; zoom scales every FlexCore control together.

Keyboard and accessibility

  • Renders a real <button>: Space and Enter activate it, it takes part in forms, and screen readers announce its role.
  • Icon-only buttons need Title plus aria-label; the icon span carries no text.
  • Dropdown mode sets aria-haspopup and aria-expanded.
  • Inside DialogControl, Enter fires the default button through DefaultButtonScope; a control that needs Enter for itself calls ConsumeEnter().
An unhandled error has occurred. Reload 🗙

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.