HxCollapse

Bootstrap 5 Collapse component.

Basic Usage

Some placeholder content for the collapse component. This panel is hidden by default but revealed when the user activates the relevant trigger.
<HxCollapseToggleButton Text="Toggle" CollapseTarget="#myCollapse" Color="ThemeColor.Primary" CssClass="mb-3" />
<HxCollapse Id="myCollapse">
	<HxCard>
		<BodyTemplate>
			Some placeholder content for the collapse component.
			This panel is hidden by default but revealed when the user activates the relevant trigger.
		</BodyTemplate>
	</HxCard>
</HxCollapse>

Horizontal

You can change the animation direction with CollapseDirection parameter.

This is some placeholder content for a horizontal collapse. It's hidden by default and shown when triggered.

Multiple targets

You can use the CollapseTarget selector to toggle multiple targets.

Some placeholder content for the first collapse component of this multi-collapse example. This panel is hidden by default but revealed when the user activates the relevant trigger.
Some placeholder content for the second collapse component of this multi-collapse example. This panel is hidden by default but revealed when the user activates the relevant trigger.

Custom toggle element

Use HxCollapseToggleElement (with ElementName="...") instead of HxCollapseToggleButton to create custom toggler (usually you will add role="button" to apply pointer cursor type).

Custom toggle element
Some placeholder content for the collapse component. This panel is hidden by default but revealed when the user activates the relevant trigger.

Programming

Some placeholder content for the collapse component. This panel is hidden by default but revealed when the user activates the relevant trigger.

API

Parameters

Name Type Description
ChildContent RenderFragment Content of the collapse.
CollapseDirection CollapseDirection Direction of the animation. Default is CollapseDirection.Vertical.
CssClass string Additional CSS class.
Id string Element ID. To be referenced by HxCollapseToggleButton.CollapseTarget. (Autogenerated GUID if not set explicitly.)
OnHidden EventCallback<string> This event is fired when a collapse element has been hidden from the user (will wait for CSS transitions to complete).
OnShown EventCallback<string> This event is fired when a collapse element has been made visible to the user (will wait for CSS transitions to complete).
Parent string If parent is provided, then all collapsible elements under the specified parent will be closed when this collapsible item is shown. (Similar to traditional accordion behavior.)

Methods

Method Returns Description
HideAsync() Task Collapses the item.
ShowAsync() Task Expands the item.

HxCollapseToggleButton

Bootstrap Collapse toggle (in form of button) which triggers the HxCollapse to toggle. Derived from HxButton (incl. HxButton.Defaults inheritance).

API

Parameters

Name Type Description
AdditionalAttributes Dictionary<string, TValue> Additional attributes to be splatted onto an underlying <button> element.
ChildContent RenderFragment Button content.
CollapseTarget string Target selector of the toggle. Use #id to reference single HxCollapse or .class for multiple HxCollapses.
Color ThemeColor? Bootstrap button style - theme color.
Default is taken from HxButton.Defaults (ThemeColor.None if not customized).
CssClass string Custom CSS class to render with the <button />.
When using Tooltip you might want to use TooltipWrapperCssClass instead of CssClass to get the desired result.
EditContext EditContext Associated EditContext.
Enabled bool?
FormId string Specifies the form the button belongs to.
Icon IconBase Icon to render into the button.
IconPlacement ButtonIconPlacement? Position of the icon within the button. Default is ButtonIconPlacement.Start (configurable through HxButton.Defaults).
OnClick EventCallback<MouseEventArgs> Raised after the button is clicked.
OnClickPreventDefault bool Prevents the default action for the onclick event. Deafult is false.
OnClickStopPropagation bool Stop onClick-event propagation. Deafult is true.
OnInvalidClick EventCallback<MouseEventArgs> Raised after the button is clicked and EditContext validation fails.
OnValidClick EventCallback<MouseEventArgs> Raised after the button is clicked and EditContext validation succeeds.
Outline bool? Bootstrap "outline" button style.
Settings ButtonSettings Set of settings to be applied to the component instance (overrides HxButton.Defaults, overriden by individual parameters).
SingleClickProtection bool Set false if you want to allow multiple OnClick handlers in parallel. Default is true.
Size ButtonSize? Button size. Default is ButtonSize.Regular.
Spinner bool? Set state of the embedded HxSpinner. Leave null if you want automated spinner when any of the OnClick handlers is running. You can set an explicit false constant to disable (override) the spinner automation.
Text string Text of the button.
Tooltip string Tooltip text.
If set, a span wrapper will be rendered around the <button />. For most scenarios you will then use TooltipWrapperCssClass instead of CssClass.
TooltipCssClass string Custom CSS class to render with the tooltip.
TooltipPlacement TooltipPlacement Tooltip placement.
TooltipWrapperCssClass string Custom CSS class to render with the tooltip span wrapper of the <button />.
If set, the span wrapper will be rendered no matter the Tooltip text is set or not.

Static properties

Property Type Description
Defaults ButtonSettings Application-wide defaults for HxButton and derived components.

HxCollapseToggleElement

Bootstrap Collapse toggle triggering the HxCollapse to toggle.

API

Parameters

Name Type Description
AdditionalAttributes IDictionary<string, TValue> A collection of additional attributes that will be applied to the created element.
ChildContent RenderFragment Content of the component.
CollapseTarget string Target selector of the toggle. Use #id to reference single HxCollapse or .class for multiple HxCollapses.
CssClass string Custom CSS class to render with the toggle element.
ElementName string Gets or sets the name of the element to render. Default is span.
An unhandled error has occurred. Reload 🗙