ActionButton
Description
The ActionButton component is a composite UI control that combines a display area and an associated action button. It is designed to enable users to trigger an action either by clicking on the main display or the separate action icon. Use this component when you want a button that can provide both a main interactive area and an additional action trigger, typically in contexts where extra functionality or a dropdown/callout is needed.
Usage
To instantiate an ActionButton, use the static helper method provided by Tesserae.UI. You can specify display text, icons, and even customize behavior by chaining method calls such as setting click event handlers. The component supports several overloads, accommodating a simple text label with optional icons or an entire IComponent as its display content.
Below is a sample that creates various ActionButtons with different visual styles and behaviors:
API reference
public class ActionButton : IComponent, IHasBackgroundColorA borderless, lightweight button typically used for inline actions inside cards, lists or toolbars.
Constructors
public ActionButton( string textContent, UIcons displayIcon, UIconsWeight displayIconWeight = UIconsWeight.Regular, string displayColor = null, TextSize displayIconSize = TextSize.Small, UIconsWeight actionIconWeight = UIconsWeight.Regular, UIcons actionIcon = UIcons.AngleCircleDown, string actionColor = null, TextSize actionIconSize = TextSize.Small) : this(HStack().Children(Icon(displayIcon, displayIconWeight, displayIconSize, displayColor), TextBlock(textContent).PL(8)), Icon.Transform(actionIcon, actionIconWeight), actionColor, actionIconSize)Initializes a new instance of this class.
public ActionButton( string textContent, UIcons displayIcon, UIconsWeight actionIconWeight = UIconsWeight.Regular, UIcons actionIcon = UIcons.AngleCircleDown, string actionColor = null, TextSize actionIconSize = TextSize.Small) : this(HStack().Children(Icon(displayIcon), TextBlock(textContent).PL(8)), Icon.Transform(actionIcon, actionIconWeight), actionColor, actionIconSize)Initializes a new instance of this class.
public ActionButton( string textContent, UIcons actionIcon = UIcons.AngleCircleDown, UIconsWeight actionIconWeight = UIconsWeight.Regular, string actionColor = null, TextSize actionIconSize = TextSize.Small) : this(TextBlock(textContent), Icon.Transform(actionIcon, actionIconWeight), actionColor, actionIconSize)Initializes a new instance of this class.
Properties
public HTMLDivElement Container { get; protected set; }Gets or sets the container.
public HTMLDivElement DisplayButton { get; protected set; }Gets or sets the display button.
public HTMLButtonElement ActionBtn { get; protected set; }Gets or sets the action btn.
public IComponent ActionBtnComponent { get; protected set; }Gets or sets the action btn component.
public string Background { get ; set ; }Gets or sets the CSS background of the component.
public bool IsDanger { get ; set ; }Gets or set whenever button is danger
public bool IsPrimary { get ; set ; }Gets or set whenever button is primary
Methods
public virtual ActionButton OnClickDisplay(ActionButtonEventHandler<HTMLDivElement, MouseEvent> onClick, bool clearPrevious = true)Registers a callback invoked when the click display event fires.
public virtual ActionButton OnClickAction(ActionButtonEventHandler<HTMLButtonElement, MouseEvent> onClick, bool clearPrevious = true)Registers a callback invoked when the click action event fires.
public ActionButton ModifyActionButton(Action<IComponent> modify)Configures the modify action button on the component.
Samples
Basic ActionButton
The following sample demonstrates a basic ActionButton with click handlers for both its display and action areas:
Customized ActionButton with Styling
This sample shows how to create an ActionButton with custom icons and styling, as well as how to modify the action button component—for instance, to set a tooltip: