Skip to content

NotificationIconWidget

Namespace: Hex1b.Widgets

Assembly: Hex1b.dll

A notification bell icon widget that displays the notification count and toggles the drawer.

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

Inheritance

ObjectHex1bWidgetNotificationIconWidget

Implements

Properties

BellCharacter

The bell character to display. Defaults to "🔔".

Returns: String

csharp
public string BellCharacter { get; init; }

ShowCount

Whether to show the notification count badge next to the bell. Defaults to true.

Returns: Boolean

csharp
public bool ShowCount { get; init; }

Methods

WithBell(string)

Sets the bell character to display.

Parameters:

  • bell (String): The character or string to use as the bell icon.

Returns: NotificationIconWidget

A new widget instance with the bell character configured.

csharp
public NotificationIconWidget WithBell(string bell)

WithCount(bool)

Sets whether to show the notification count badge.

Parameters:

  • show (Boolean): True to show the count (default), false to hide it.

Returns: NotificationIconWidget

A new widget instance with the setting configured.

csharp
public NotificationIconWidget WithCount(bool show = true)

Fields

TogglePanelAction

Returns: ActionId

csharp
public static readonly ActionId TogglePanelAction

Remarks

The notification icon displays a bell character (🔔 by default) followed by the unread notification count. When clicked or activated with Enter, it toggles the notification drawer.

Requirements: This widget must be placed inside a subtree to function correctly. It automatically discovers the parent panel's notification stack.

Keyboard shortcuts: Alt+N toggles the notification drawer from anywhere in the app.Enter or Space activates the icon when focused.

Examples

A typical menu bar with notification icon:

csharp
ctx.ZStack(z => [
    z.VStack(v => [
        v.HStack(bar => [
            bar.Button("File"),
            bar.Button("Edit"),
            bar.Text("").FillWidth(), // Spacer
            bar.NotificationIcon()
        ]),
        v.NotificationPanel(
            v.Text("Main content here")
        ).Fill()
    ])
])

Released under the MIT License.