Skip to content

NotificationPanelWidget

Namespace: Hex1b.Widgets

Assembly: Hex1b.dll

A notification panel widget that hosts notifications and displays them as floating overlays or in a slide-out drawer.

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

Inheritance

ObjectHex1bWidgetNotificationPanelWidget

Implements

Properties

DrawerFloats

Whether the drawer floats on top of content (true) or pushes content aside (false). Defaults to true (floating).

Returns: Boolean

csharp
public bool DrawerFloats { get; init; }

EnableAnimation

Whether to enable animation for timeout progress bars. Defaults to true.

Returns: Boolean

csharp
public bool EnableAnimation { get; init; }

MaxFloating

Maximum number of floating notifications to show at once. Defaults to 3.

Returns: Int32

csharp
public int MaxFloating { get; init; }

OffsetX

Horizontal offset from the right edge for floating notifications. Defaults to 2.

Returns: Int32

csharp
public int OffsetX { get; init; }

OffsetY

Vertical offset from the top edge for floating notifications. Defaults to 1.

Returns: Int32

csharp
public int OffsetY { get; init; }

Methods

WithAnimation(bool)

Enables or disables animation for timeout progress bars.

Parameters:

  • enable (Boolean): True to enable animation (default), false to disable.

Returns: NotificationPanelWidget

A new widget instance with the setting configured.

csharp
public NotificationPanelWidget WithAnimation(bool enable = true)

WithContent(Hex1bWidget)

Sets the content widget that notifications will overlay.

Parameters:

Returns: NotificationPanelWidget

A new widget instance with the content configured.

csharp
public NotificationPanelWidget WithContent(Hex1bWidget content)

WithDrawerFloats(bool)

Sets whether the drawer floats on top of content or pushes content aside.

Parameters:

  • floats (Boolean): True for floating overlay (default), false to push content aside.

Returns: NotificationPanelWidget

A new widget instance with the setting configured.

csharp
public NotificationPanelWidget WithDrawerFloats(bool floats = true)

WithMaxFloating(int)

Sets the maximum number of floating notifications visible at once.

Parameters:

  • max (Int32): Maximum floating notifications. Defaults to 3.

Returns: NotificationPanelWidget

A new widget instance with the setting configured.

csharp
public NotificationPanelWidget WithMaxFloating(int max)

WithOffset(int, int)

Sets the offset from the corner for floating notifications.

Parameters:

  • x (Int32): Horizontal offset from right edge in columns.
  • y (Int32): Vertical offset from top edge in rows.

Returns: NotificationPanelWidget

A new widget instance with the offsets configured.

csharp
public NotificationPanelWidget WithOffset(int x, int y)

Fields

ToggleDrawerAction

Returns: ActionId

csharp
public static readonly ActionId ToggleDrawerAction

Remarks

The notification panel is the container that manages notification display. It wraps your main content and provides: Floating notifications: Appear in the top-right corner as overlay cards.Notification drawer: A slide-out panel showing all notifications.Timeout management: Automatically hides notifications after their timeout.

Typical layout pattern:

csharp
ctx.ZStack(z => [
    z.VStack(v => [
        v.HStack(bar => [
            bar.Button("Menu"),
            bar.NotificationIcon()
        ]),
        v.NotificationPanel(
            v.Text("Your main content here")
        ).Fill()
    ])
])

Posting notifications: Access the notification stack through the input context and call Post():

csharp
ctx.Button("Notify").OnClick(e => {
    e.Context.Notifications.Post(
        new Notification("Hello!", "This is a notification")
            .Timeout(TimeSpan.FromSeconds(5))
    );
})

Keyboard shortcuts: Alt+N toggles the notification drawer.Escape closes the drawer when open.

Examples

A complete notification-enabled application:

csharp
var app = new Hex1bApp(ctx => ctx.ZStack(z => [
    z.VStack(v => [
        v.HStack(bar => [
            bar.Button("File"),
            bar.Text("").FillWidth(),
            bar.NotificationIcon()
        ]),
        v.NotificationPanel(
            v.Button("Show Notification").OnClick(e => {
                e.Context.Notifications.Post(
                    new Notification("Task Complete", "Your task finished successfully")
                        .Timeout(TimeSpan.FromSeconds(5))
                        .PrimaryAction("View", async ctx => { /* view result */ })
                );
            })
        ).Fill()
    ])
]));

Released under the MIT License.