Class ActionModelBuilder
- Namespace
- Htmx.Components.Models.Builders
- Assembly
- Htmx.Components.dll
Builder for creating individual ActionModel instances with detailed configuration. Provides fluent configuration for buttons, links, and other interactive action elements.
public class ActionModelBuilder : BuilderBase<ActionModelBuilder, ActionModel>
- Inheritance
-
ActionModelBuilder
- Inherited Members
- Extension Methods
Constructors
ActionModelBuilder(IServiceProvider)
Initializes a new instance of the ActionModelBuilder with the specified service provider.
public ActionModelBuilder(IServiceProvider serviceProvider)
Parameters
serviceProvider
IServiceProviderThe service provider for dependency injection
Methods
BuildImpl()
Builds the final ActionModel instance with all configured properties. This method is called internally to create the final result.
protected override Task<ActionModel> BuildImpl()
Returns
- Task<ActionModel>
A task that represents the asynchronous build operation, containing the built ActionModel
WithAttribute(string, string)
Adds a custom HTML attribute to the action element. Useful for data attributes, accessibility properties, or custom behavior.
public ActionModelBuilder WithAttribute(string name, string value)
Parameters
Returns
- ActionModelBuilder
The current builder instance for method chaining
WithClass(string)
Sets CSS classes to apply to the action element. Used for styling, theming, and layout customization.
public ActionModelBuilder WithClass(string cssClass)
Parameters
cssClass
stringThe CSS class names to apply
Returns
- ActionModelBuilder
The current builder instance for method chaining
WithHxGet(string)
Sets the HTMX hx-get attribute for HTTP GET requests.
public ActionModelBuilder WithHxGet(string url)
Parameters
url
stringThe URL to request when the action is triggered
Returns
- ActionModelBuilder
The current builder instance for method chaining
WithHxInclude(string)
Sets the HTMX hx-include attribute to include additional elements in requests.
public ActionModelBuilder WithHxInclude(string selector)
Parameters
selector
stringThe CSS selector for elements to include
Returns
- ActionModelBuilder
The current builder instance for method chaining
WithHxPost(string)
Sets the HTMX hx-post attribute for HTTP POST requests.
public ActionModelBuilder WithHxPost(string url)
Parameters
url
stringThe URL to request when the action is triggered
Returns
- ActionModelBuilder
The current builder instance for method chaining
WithHxPushUrl(string)
Sets the HTMX hx-push-url attribute to control browser history.
public ActionModelBuilder WithHxPushUrl(string pushUrl = "true")
Parameters
pushUrl
stringThe URL to push to browser history, or "false" to disable
Returns
- ActionModelBuilder
The current builder instance for method chaining
WithHxSwap(string)
Sets the HTMX hx-swap attribute to specify how content should be swapped.
public ActionModelBuilder WithHxSwap(string swap)
Parameters
swap
stringThe swap strategy (innerHTML, outerHTML, afterbegin, etc.)
Returns
- ActionModelBuilder
The current builder instance for method chaining
WithHxTarget(string)
Sets the HTMX hx-target attribute to specify where response content should be placed.
public ActionModelBuilder WithHxTarget(string target)
Parameters
target
stringThe CSS selector for the target element
Returns
- ActionModelBuilder
The current builder instance for method chaining
WithIcon(string)
Sets the icon for the action. Icons provide visual identification and can be CSS classes or icon font references.
public ActionModelBuilder WithIcon(string icon)
Parameters
icon
stringThe icon identifier (CSS class, font icon, etc.)
Returns
- ActionModelBuilder
The current builder instance for method chaining
WithIsActive(bool)
Sets whether the action is currently active or selected. Active actions typically receive different styling to indicate current state.
public ActionModelBuilder WithIsActive(bool isActive)
Parameters
isActive
boolTrue if the action should be marked as active
Returns
- ActionModelBuilder
The current builder instance for method chaining
WithLabel(string)
Sets the display label for the action. The label is the text shown to users for buttons, links, or menu items.
public ActionModelBuilder WithLabel(string label)
Parameters
label
stringThe text label to display
Returns
- ActionModelBuilder
The current builder instance for method chaining