Skip to main content

LgNavigationBox

LgNavigationBox is a navigation search area. It displays a list of pages (TPageLink : IPageLink) in a dropdown menu, filters results based on entered text, and navigates to the URI of the selected item.

<LgNavigationBox Items="_items" Placeholder="#menuSearchSetAria" />
  • Namespace: Lagoon.UI.Components
  • Inherits from: LgSuggestBoxBase<TPageLink> → LgTextBox → LgInputRenderBase<string> → LgInputBase<string> → LgAriaComponentBase → LgComponentBase
  • Interfaces: ILgDropDownComponent, IInputCommonProperties, ILgComponentPolicies, IInputBusy, ILgFocusableComponent
  • NuGet package: Lagoon.UI
Local or remote data

Items provides a local list. ControllerUri allows loading results remotely with the same text filtering on the component side.

Usage​

Demonstration​

Try this component in the Lagoon showcase.

Local page list​

For a list of pages known on the client side, provide Items. The component searches in the Title of each IPageLink and navigates to Uri on click or keyboard validation.

SearchPage.razor
@inherits LgPage

<LgNavigationBox Items="_items"
Label="#SearchPage"
Placeholder="#SearchNavigationPlaceholder"
MinSearchCharacter="1"
MaxItemsInView="8" />
SearchPage.razor.cs
public partial class SearchPage : LgPage
{
// Pages offered in local search; typed links avoid duplicate routes.
private readonly List<LgPageLink> _items = new()
{
DashboardPage.Link(),
OrdersPage.Link(),
CustomersPage.Link(),
ReportsPage.Link()
};
}

Remote search with ControllerUri​

When the list depends on permissions or server data, use ControllerUri. The component automatically posts a data request to {ControllerUri}/$qd with the entered text, pagination, and filtering on Title.

AppLayout.razor
@inherits LgComponentBase

<LgNavigationBox ControllerUri="api/navigation/pages"
Label="#Search"
Placeholder="#SearchNavigationPlaceholder"
MinSearchCharacter="2"
MaxItemsInView="10"
TextFilterCollation="CollationType.IgnoreCaseAndAccent" />

Endpoint contract​

ControllerUri points to a queryable action. The component calls {ControllerUri}/$qd in POST via the Lagoon remote loader; the source action remains exposed as GET and decorated with [Queryable].

GET + POST $qd — Page search (ControllerUri)​

NavigationController.cs
[ApiController]
[Route("api/navigation")]
public class NavigationController : LgControllerBase
{
[HttpGet("pages")]
[Queryable]
public IQueryable<LgPageLink> GetPages()
{
// Build the complete list server-side to apply permissions or business rules before filtering.
List<LgPageLink> pages = new()
{
DashboardPage.Link(),
OrdersPage.Link(),
CustomersPage.Link(),
ReportsPage.Link()
};

// Return IQueryable to let [Queryable] apply the search text, pagination, and sorts.
return pages.AsQueryable();
}
}
Local or remote data

Items is simpler for a static list. ControllerUri becomes relevant if the list is large, dynamic, or filtered by permissions computed on the server side.

Filtering, collation, and result count​

FilterTextSearchMode, TextFilterCollation, MinSearchCharacter, and MaxItemsInView allow adjustment of the search behavior.

SearchPage.razor
@inherits LgPage

<LgNavigationBox Items="_items"
Placeholder="#SearchNavigationPlaceholder"
FilterTextSearchMode="FilterTextSearchMode.StartsWith"
TextFilterCollation="CollationType.IgnoreCaseAndAccent"
MinSearchCharacter="0"
MaxItemsInView="0" />
ParameterEffect
MinSearchCharacter="0"Opens the search even without input.
MaxItemsInView="0"Displays all available results.
FilterTextSearchModeChooses Contains, StartsWith, or EndsWith.
TextFilterCollationManages case and accents during filtering.

Customize result rendering​

ItemContent replaces the default rendering. If HighlightText is enabled, add the highlightable class to the element containing the text to highlight.

SearchPage.razor
@inherits LgPage

<LgNavigationBox Items="_items" HighlightText="true" Placeholder="#SearchNavigationPlaceholder">
<ItemContent Context="item">
<LgIcon IconName="@item.IconName" />
<span class="highlightable">@item.Title.CheckTranslate()</span>
</ItemContent>
</LgNavigationBox>

Without ItemContent, the component automatically displays the icon IconName and translated title Title in an internal LgHyperlink.

Properties​

All [Parameter] properties of the component, including inherited ones.

NameTypeDefaultDeclared inDescription
ControllerUristringnullLgSuggestBoxBase<TItem>URI of the controller used to load results remotely.
DropDownMaxHeightint-1LgSuggestBoxBase<TItem>Maximum height of the dropdown menu, in pixels. -1 uses available space.
FilterTextSearchModeFilterTextSearchModeFilterTextSearchMode.ContainsLgSuggestBoxBase<TItem>Comparison mode used to filter the searched text.
HighlightTextboolfalseLgSuggestBoxBase<TItem>Highlights found text in displayed results.
ItemContentRenderFragment<TPageLink>nullLgSuggestBoxBase<TItem>Custom template for rendering a result.
ItemsIEnumerable<TPageLink>nullLgSuggestBoxBase<TItem>Local source of offered pages.
MaxItemsInViewint8LgSuggestBoxBase<TItem>Maximum number of displayed results. 0 shows all results.
MinSearchCharacterint0LgSuggestBoxBase<TItem>Minimum number of characters before starting the search.
TextFilterCollationCollationType?nullLgSuggestBoxBase<TItem>Sensitivity to case and accents. If null, the value of App.BehaviorConfiguration.TextFilterCollation.Value is used at initialization.
AllowResizeboolfalseLgTextBoxAllows resizing when TextMode is TextBoxMode.Multiline.
AutoCompleteboolfalseLgTextBoxEnables browser autocompletion if true; otherwise the autocomplete="off" attribute is rendered.
AutoUnmaskboolfalseLgTextBoxReturns the value without the mask when InputMask is used.
ClearIncompleteboolfalseLgTextBoxClears the value if the input mask is incomplete.
DataListList<string>nullLgTextBoxList of values used to render a datalist associated with the input.
InputMaskstringnullLgTextBoxInput mask applied to the text field.
InputMaskKindInputMaskKindInputMaskKind.NoneLgTextBoxType of input mask.
MaxLengthint?nullLgTextBoxMaximum number of characters. If not set, it is deduced from Container or the model's MaxLength attribute, otherwise 0.
MaxRowsint?nullLgTextBoxMaximum number of lines when TextMode is TextBoxMode.Multiline.
MinRowsint?nullLgTextBoxMinimum number of lines when TextMode is TextBoxMode.Multiline.
OnChangingAsyncFunc<ChangingEventArgs<string>, Task>nullLgTextBoxCallback called before value change; it can cancel the change.
OnChangeDisabledboolfalseLgTextBoxDisables the native onchange handler of the field.
OnFocusEventCallback<FocusEventArgs>—LgTextBoxCallback triggered when the field receives focus.
OnInputEventCallback<ChangeEventArgs>—LgTextBoxCallback triggered on input (oninput).
OnKeyUpEventCallback<KeyboardEventArgs>—LgTextBoxCallback triggered on key release.
PlaceholderstringnullLgTextBoxPlaceholder of the search field.
Rowsint?nullLgTextBoxNumber of lines when TextMode is TextBoxMode.Multiline.
TextModeTextBoxMode?nullLgTextBoxText field mode. null renders a simple text field.
PrefixstringIconNames.All.SearchLgInputRenderBase<TValue>Prefix displayed before the field. The LgNavigationBox constructor sets it to the search icon.
PrefixTypeInputLabelTypeInputLabelType.IconNameLgInputRenderBase<TValue>Type of prefix rendering.
SuffixstringnullLgInputRenderBase<TValue>Suffix displayed after the field.
SuffixTypeInputLabelTypeInputLabelType.TextLgInputRenderBase<TValue>Type of suffix rendering.
AdditionalAttributesIReadOnlyDictionary<string, object>nullLgInputBase<TValue>Additional HTML attributes applied to the main container (captures unmapped values).
AutoFocusboolfalseLgInputBase<TValue>Gives focus to the field on first render.
ConfirmationMessagestringnullLgInputBase<TValue>Confirmation message displayed before applying a new value.
ContainerIInputContainer<string>nullLgInputBase<TValue>Internal container used notably by LgGridView cells.
CssClassstringnullLgInputBase<TValue>Additional CSS classes of the form group.
DisabledboolfalseLgInputBase<TValue>Disables the field.
DisplayNamestringnullLgInputBase<TValue>Display name used in validation and parsing messages.
HideValidationMessageboolfalseLgInputBase<TValue>Hides inline validation messages.
LabelstringnullLgInputBase<TValue>Label of the field.
LabelContentRenderFragmentnullLgInputBase<TValue>Custom label content.
OnChangeEventCallback<ChangeEventArgs>—LgInputBase<TValue>Callback called after applying a new value.
OnResetEventCallback<ChangeEventArgs>—LgInputBase<TValue>Callback called when the reset button restores the value to default.
PolicyEditstringnullLgInputBase<TValue>Policy required to edit the field.
PolicyVisiblestringnullLgInputBase<TValue>Policy required to display the field.
ReadOnlyboolfalseLgInputBase<TValue>Renders the field as read-only.
Requiredbool?nullLgInputBase<TValue>Indicates whether the field is required. If null, the information is deduced from the model's [Required] attribute.
ResetButtonbool?nullLgInputBase<TValue>Shows the reset button. If null, application configuration is used.
ResetTextstringnullLgInputBase<TValue>Text of the reset button; application configuration is used if not set.
ResetTextAriaLabelstringnullLgInputBase<TValue>ARIA label of the reset button; application configuration is used if not set.
TooltipstringnullLgInputBase<TValue>Tooltip of the field.
TooltipIsHtmlboolfalseLgInputBase<TValue>Indicates whether Tooltip content is in HTML format.
ValuestringnullLgInputBase<TValue>Field value, usable with @bind-Value.
ValueChangedEventCallback<string>—LgInputBase<TValue>Callback for two-way binding of Value.
ValueExpressionExpression<Func<string>>nullLgInputBase<TValue>Expression identifying the bound value, used by Blazor validation.
AriaLabelstringnullLgAriaComponentBaseValue of the aria-label attribute.
AriaLabelledBystringnullLgAriaComponentBaseValue of the aria-labelledby attribute.
Cascading parameters

LgNavigationBox also consumes parameters automatically provided by ancestor components: CascadedEditContext (EditContext), EditFormConfiguration (LgEditFormConfiguration), ParentAuthorizeView (LgAuthorizeView), InputBusyReference (InputBusyReference), and ContextProvider (IComponentContextProvider, inherited from LgComponentBase).

Events​

EventTypeDescription
ValueChangedEventCallback<string>Callback generated by @bind-Value when the value changes.
OnChangeEventCallback<ChangeEventArgs>Triggered after a new value is applied.
OnChangingAsyncFunc<ChangingEventArgs<string>, Task>Called before value change; the change can be canceled.
OnFocusEventCallback<FocusEventArgs>Triggered when the field receives focus.
OnInputEventCallback<ChangeEventArgs>Triggered during input and used by the search.
OnKeyUpEventCallback<KeyboardEventArgs>Triggered on key release.
OnResetEventCallback<ChangeEventArgs>Triggered when the reset button restores the value to default.

Associated enumerations​

FilterTextSearchMode​

ValueDescription
ContainsThe searched text is contained in the value.
StartsWithThe value starts with the searched text.
EndsWithThe value ends with the searched text.

CollationType​

ValueDescription
CaseSensitiveSensitive to case and accents.
IgnoreCaseInsensitive to case, sensitive to accents.
IgnoreCaseAndAccentInsensitive to case and accents.

InputLabelType​

ValueDescription
IconNameThe prefix or suffix is a Lagoon icon name.
TextThe prefix or suffix is plain text.

InputMaskKind​

ValueDescription
NoneNo mask.
MaskMask based on 9, a and *.
RegexMask based on a regular expression.
EmailEmail input mask.

TextBoxMode​

ValueDescription
MultilineRenders a multiline text area.
PasswordRenders a password field.

Accessibility​

  • Provide Label, AriaLabel, or AriaLabelledBy to name the search field.
  • The constructor configures a search icon prefix IconNames.All.Search; keep an accessible label because the icon alone is not sufficient.
  • The attributes aria-required, aria-readonly, aria-invalid, and aria-describedby are managed by the input base according to validation and field state.
  • LgHyperlink — component used to render navigation results.
  • LgNavLink — navigation link with automatic active state.
  • LgButton — alternative to trigger navigation from a button action.