METADATA
=======
Last Updated: 2026-09-19 06:33 UTC
Title: BlazorBlueprint - Common Patterns and Conventions
Library Version: 4
Most interactive components expose a Value parameter and a ValueChanged callback
for standard Blazor two-way binding:
This desugars to:
Text input components (BbInput, BbTextarea, BbInputGroupInput, BbInputGroupTextarea)
implement their own Value/ValueChanged pattern directly on ComponentBase.
They do NOT inherit from InputBase.
Specialized inputs (BbNumericInput, BbCurrencyInput, BbMaskedInput) also have their
own value handling with type-specific parsing.
================================================================================
CONTROLLED VS UNCONTROLLED STATE
================================================================================
Many components support both controlled and uncontrolled modes:
Controlled (you manage the state):
...
Or with @bind shorthand:
...
Uncontrolled (component manages its own state):
...
Applies to: Open/DefaultOpen, Value/DefaultValue, and similar parameter pairs.
Components with a nullable `Open` (bool?) plus `OpenChanged`: BbAlertDialog,
BbContextMenu, BbDialog, BbDrawer, BbDropdownMenu, BbHoverCard, BbPopover,
BbSelect, BbSheet, BbTooltip and BbSidebarProvider. Leaving `Open` null
keeps the component uncontrolled. BbSidebarProvider has a second pair,
`OpenMobile`/`OpenMobileChanged`, for the mobile drawer; binding `Open` on it turns
off its cookie persistence.
================================================================================
ONVALUECHANGE CALLBACKS
================================================================================
Some components provide an OnValueChange (or similar On*Change) callback that
fires when the value changes but does NOT control the state. This is a one-way
notification useful for side effects like logging or analytics:
...
The difference from ValueChanged:
- ValueChanged: Part of two-way binding. Setting Value + ValueChanged means
YOU control the state.
- OnValueChange: Notification only. The component still manages its own state
internally.
================================================================================
FORM INTEGRATION
================================================================================
For EditForm validation, value components support:
- Value / ValueChanged: The bound value
- ValueExpression: An Expression> pointing to the bound property,
used to identify the field for validation messages
`@bind-Value` generates Value, ValueChanged and ValueExpression for you. Do not
also set ValueExpression explicitly next to `@bind-Value`; Razor rejects a
parameter supplied twice.
Example:
Set ValueExpression yourself only when binding with separate Value and
ValueChanged attributes:
Multi-value components bind a collection through `Values`/`ValuesChanged` and use
`ValuesExpression` the same way (for example BbTreeSelect in multiple mode,
where `@bind-Values` supplies it).
When inside an EditForm, components automatically detect the cascaded
EditContext and integrate with Blazor's validation system.
================================================================================
OVERLAY / PORTAL PATTERN
================================================================================
Overlay components (BbDialog, BbSheet, BbPopover, BbTooltip, BbDropdownMenu, BbHoverCard,
BbContextMenu, BbSelect and the others) render their content through the BbPortalHost component.
How it works:
1. BbPortalHost must be placed in your root layout (MainLayout.razor), in the
same render-mode scope as the interactive content that opens overlays
2. Overlay components register their content with IPortalService (floating
overlays through BbFloatingPortal, dialogs through BbDialogPortal, sheets
through BbSheetPortal)
3. BbPortalHost renders the registered content where it is placed in the layout
4. IPositioningService handles floating UI positioning (for BbPopover,
BbTooltip, BbDropdownMenu and the other floating overlays)
This ensures overlays are not clipped by parent overflow or z-index contexts.
Native dialog exception: ``
renders the browser's own