Skip to main content

LgFrame

LgFrame is Lagoon's standard container for grouping a header, body, summary, and footer. It can also embed a toolbar and become collapsible to temporarily hide its content.

<LgFrame Title="Résumé">
Contenu principal
</LgFrame>
  • Namespace: Lagoon.UI.Components
  • Inherits from: LgAriaComponentBase → LgComponentBase
  • NuGet package: Lagoon.UI
Collapsed Summary

SummaryContent is rendered only if the frame is Collapsable and currently collapsed. Use it to display a summary state when the main content is hidden.

Usage​

Demonstration​

Try this component in the Lagoon showcase.

Simple frame or headerless frame​

If the frame contains only a body, ChildContent is implicit. Omit Title for an empty header, or use ShowHeader="false" to hide the entire header area.

SimpleFramePage.razor
@inherits LgPage

<LgFrame Title="#OrderFrameTitle"
IconName="@IconNames.All.InfoCircle"
Kind="Kind.Primary">
<p>@("#OrderFrameContent".Translate())</p>
</LgFrame>

<LgFrame ShowHeader="false"
ChildCssClass="p-3"
CssClass="mt-3">
<p>@("#NoHeaderFrameContent".Translate())</p>
</LgFrame>

Collapsed supports two-way binding. DefaultCollapsed initializes the state on first render; then, preserve the state with @bind-Collapsed and react via OnToggle.

OrderSummaryPage.razor
@inherits LgPage

<LgFrame Kind="Kind.Info"
IconName="@IconNames.All.InfoCircle"
ButtonSize="ButtonSize.Small"
Collapsable="true"
DefaultCollapsed="true"
@bind-Collapsed="_isCollapsed"
OnToggle="OnFrameToggleAsync"
OnCommand="OnFrameCommandAsync"
HeaderCssClass="order-frame-header"
ChildCssClass="order-frame-body">
<TitleContent>
<LgTitle Text="#OrderSummaryTitle" Level="2" />
</TitleContent>
<Toolbar>
<LgToolbarButton Text="#ExportOrder"
IconName="@IconNames.All.Pdf"
CommandName="export-order" />
</Toolbar>
<HeaderContent>
<span>@("#OrderNumberLabel".Translate()) @_orderNumber</span>
</HeaderContent>
<ChildContent>
<p>@("#OrderAmountLabel".Translate()) @_totalAmount</p>
<p>@("#FrameLastEvent".Translate()) @(_lastFrameEventKey.Translate())</p>
</ChildContent>
<SummaryContent>
<p>@("#OrderCollapsedSummary".Translate()) @_orderNumber</p>
</SummaryContent>
<FooterContent>
<p>@("#OrderUpdatedAt".Translate()) @_lastRefreshLabel</p>
</FooterContent>
</LgFrame>
OrderSummaryPage.razor.cs
public partial class OrderSummaryPage : LgPage
{
// Retains the collapsed state to restore the display chosen by the user.
private bool _isCollapsed = true;

// Business data displayed in the header and in the collapsed summary.
private string _orderNumber = "CMD-2024-0042";

// Demo amount rendered in the frame body.
private decimal _totalAmount = 1245.50m;

// Label from the business model, displayed in the footer.
private string _lastRefreshLabel = "2024-06-18";

// Translation key of the last observed state, useful for tracking collapse/expand.
private string _lastFrameEventKey = "#FrameStartsCollapsed";

// Triggered on collapse/expand: persist the user state here or load content on demand.
private Task OnFrameToggleAsync(ToggleFrameEventArgs args)
{
_isCollapsed = args.Collapsed;
_lastFrameEventKey = args.Collapsed ? "#FrameCollapsed" : "#FrameExpanded";
return Task.CompletedTask;
}

// Receives commands emitted by the toolbar: centralize frame actions here.
private Task OnFrameCommandAsync(CommandEventArgs args)
{
if (args.CommandName == "export-order")
{
_lastFrameEventKey = "#FrameExportRequested";
args.Handled = true;
}

return Task.CompletedTask;
}
}

Important notes​

  • SummaryContent is rendered only if Collapsable="true" and the frame is collapsed.
  • A click in the header collapses or expands a Collapsable frame, unless it is made in a field (input, textarea, select, option) placed in the header (TitleContent, HeaderContent, or Toolbar), or on an element that stops click propagation (toolbar buttons, LgButton by default, labels of LgCheckBox, LgToggle, and LgRadio). A manually written <label> HTML element in the header collapses the frame instead of activating its field: add @onclick:stopPropagation to it.
  • Toolbar is automatically wrapped in an LgToolbar; ButtonSize drives the button size of this toolbar.
  • Kind accepts the visual variants Primary, Default, Secondary, Success, Error, Warning, and Info.
  • OnCommand receives commands from child components implementing IActionComponent, such as LgToolbarButton.

Properties​

NameTypeDefaultDeclared inDescription
ChildContentRenderFragmentnullLgFrameMain content of the frame.
FooterContentRenderFragmentnullLgFrameFooter content, rendered below the frame body.
HeaderContentRenderFragmentnullLgFrameCustom content added in the header, after the title and icon.
SummaryContentRenderFragmentnullLgFrameContent displayed instead of the body when the frame is collapsed.
TitleContentRenderFragmentnullLgFrameCustom title as markup, rendered in the title area.
ToolbarRenderFragmentnullLgFrameToolbar rendered in the header via LgToolbar.
AdditionalAttributesIReadOnlyDictionary<string, object>nullLgFrameAdditional HTML attributes applied to the root element.
ButtonSizeButtonSize?nullLgFrameSize of the toolbar buttons. If not set, the App.BehaviorConfiguration.FrameToolbarButtonSize configuration is used.
ChildCssClassstringnullLgFrameCSS classes applied to the main content area.
CollapsableboolfalseLgFrameEnables collapse/expand of the frame via the header.
CollapsedboolfalseLgFrameCurrent collapsed state.
CollapsedChangedEventCallback<bool>—LgFrameTwo-way binding callback for Collapsed.
CssClassstringnullLgFrameAdditional CSS classes applied to the frame.
DefaultCollapsedbool?nullLgFrameInitial state applied to Collapsed when initialized if the value is provided.
HeaderCssClassstringnullLgFrameCSS classes added to the header.
IconNamestringnullLgFrameIcon displayed before the frame title.
KindKindKind.PrimaryLgFrameVisual theme of the frame.
OnCommandEventCallback<CommandEventArgs>—LgFrameReceives commands bubbled by child components implementing IActionComponent.
OnToggleEventCallback<ToggleFrameEventArgs>—LgFrameCallback triggered during a collapse/expand action.
ShowHeaderbooltrueLgFrameCompletely hides the header if false.
TitlestringnullLgFrameText title of the frame.
AriaLabelstringnullLgAriaComponentBaseValue of the aria-label attribute applied to the rendered title.
AriaLabelledBystringnullLgAriaComponentBaseValue of the aria-labelledby attribute.

Events​

EventTypeDescription
CollapsedChangedEventCallback<bool>Triggered to synchronize a @bind-Collapsed.
OnCommandEventCallback<CommandEventArgs>Receives commands propagated by child components (for example a LgToolbarButton).
OnToggleEventCallback<ToggleFrameEventArgs>Triggered when a user collapses or expands the frame.

Associated Enumerations​

ButtonSize​

ButtonSize controls the ButtonSize property, used to size the toolbar buttons.

ValueDescription
MediumStandard size.
SmallReduced size (default value of standard Lagoon configuration when ButtonSize remains null).
LargeLarge size.

Kind​

Kind controls the visual theme of the frame's Kind property.

ValueDescription
PrimaryPrimary style (default value).
DefaultDefault style.
SecondarySecondary style.
Success"Success" style.
Error"Error" style (danger).
Warning"Warning" style.
Info"Information" style.