Skip to content

DrawerWidget

Namespace: Hex1b.Widgets

Assembly: Hex1b.dll

A collapsible panel widget that can be placed at the edge of an HStack or VStack. In collapsed state, it shows minimal content (or nothing). In expanded state, it shows full content with collapse/dock controls.

csharp
public sealed record DrawerWidget : Hex1bWidget, IEquatable<Hex1bWidget>, IEquatable<DrawerWidget>

Inheritance

ObjectHex1bWidgetDrawerWidget

Implements

Properties

IsExpanded

Whether the drawer is expanded. When null, the node manages its own state. When set, the drawer syncs to this value (user-controlled state).

Returns: Nullable<Boolean>

csharp
public bool? IsExpanded { get; init; }

Mode

The current rendering mode for the expanded drawer.

Returns: DrawerMode

csharp
public DrawerMode Mode { get; init; }

Methods

AsInline()

Sets the drawer to render inline (pushes adjacent content).

Returns: DrawerWidget

csharp
public DrawerWidget AsInline()

AsOverlay()

Sets the drawer to render as an overlay (floats above content).

Returns: DrawerWidget

csharp
public DrawerWidget AsOverlay()

Collapsed(bool)

Sets the drawer to collapsed state.

Parameters:

  • collapsed (Boolean): Whether the drawer should be collapsed.

Returns: DrawerWidget

csharp
public DrawerWidget Collapsed(bool collapsed = true)

CollapsedContent(Func<WidgetContext<DrawerWidget>, IEnumerable<Hex1bWidget>>)

Sets the content to display when the drawer is collapsed.

Parameters:

Returns: DrawerWidget

csharp
public DrawerWidget CollapsedContent(Func<WidgetContext<DrawerWidget>, IEnumerable<Hex1bWidget>> builder)

Expanded(bool)

Sets the drawer to expanded state.

Parameters:

  • expanded (Boolean): Whether the drawer should be expanded.

Returns: DrawerWidget

csharp
public DrawerWidget Expanded(bool expanded = true)

ExpandedContent(Func<WidgetContext<DrawerWidget>, IEnumerable<Hex1bWidget>>)

Sets the content to display when the drawer is expanded.

Parameters:

Returns: DrawerWidget

csharp
public DrawerWidget ExpandedContent(Func<WidgetContext<DrawerWidget>, IEnumerable<Hex1bWidget>> builder)

OnCollapsed(Action)

Sets the handler to call when the drawer collapses.

Parameters:

Returns: DrawerWidget

csharp
public DrawerWidget OnCollapsed(Action handler)

OnExpanded(Action)

Sets the handler to call when the drawer expands.

Parameters:

Returns: DrawerWidget

csharp
public DrawerWidget OnExpanded(Action handler)

OverlayBackground(Hex1bColor)

Sets the background color for the overlay popup content. This is required when the overlay needs an opaque background to prevent content from layers below bleeding through.

Parameters:

Returns: DrawerWidget

csharp
public DrawerWidget OverlayBackground(Hex1bColor color)

WithMode(DrawerMode)

Sets the rendering mode for the expanded drawer.

Parameters:

  • mode (DrawerMode): The rendering mode (Inline or Overlay).

Returns: DrawerWidget

csharp
public DrawerWidget WithMode(DrawerMode mode)

Fields

OpenAction

Returns: ActionId

csharp
public static readonly ActionId OpenAction

ToggleAction

Returns: ActionId

csharp
public static readonly ActionId ToggleAction

Remarks

The drawer supports two rendering modes when expanded:

  • Pushes adjacent content (like VS Code sidebar) - Floats above content (like mobile hamburger menus)

The expansion direction is auto-detected based on the drawer's position in the parent stack.

Released under the MIT License.