Skip to content
Layout App

App

The root wrapper of an app: renders the toaster, resolves the locale and sets language and direction, and cascades global class overrides.

On this page

Examples

Global overrides

Place it once in the layout, around the body, in place of a hand-placed toaster. The overrides do not cross a render mode boundary: with per-page interactivity use AddKlyrooUi for app-wide ones.

Every button is rounded
Razor
@using Klyroo.UI.Theming
@* In a real app this wraps @Body in MainLayout.razor and replaces <KlyToaster />:
   <KlyApp Lang="en" Overrides="_overrides">@Body</KlyApp>
   The site's layout already has a toaster, so this one turns it off. *@
<KlyApp Toaster="false" Lang="en" Dir="KlyDirection.Ltr" Overrides="_overrides" Class="flex flex-wrap items-center gap-3" data-testid="app">
    <KlyButton Label="Save" />
    <KlyButton Label="Cancel" Variant="ButtonVariant.Outline" Color="KlyColor.Neutral" />
    <KlyBadge Label="Every button is rounded" Variant="KlyVariant.Subtle" />
</KlyApp>

@code {
    private readonly Dictionary<Type, ISlotOverrides> _overrides = new()
    {
        [typeof(KlyButton)] = new ButtonUi { Base = "rounded-full" },
    };
}

API

KlyApp

Root wrapper of an app, placed once in the layout around the body. It renders the toaster, resolves the locale, writes the lang and dir attributes and cascades global class overrides to every component below it.

Parameters

Name Type Default Description
ApplyStoredCulture bool true In a Blazor Hybrid web view, applies the culture saved by KlyLocaleSelect ( IKlyCultureStore ) before the content renders, unless Locale is set. Turn it off when the app applies its own culture in MauiProgram . It does nothing in a browser.
Class string Classes added to the root element, merged last so they win over the theme.
Dir KlyDirection? Text direction (the dir attribute): Ltr , Rtl or Auto . Defaults to the direction of the locale. Values: Ltr, Rtl, Auto.
Lang string Language of the content (the lang attribute), for example "fr". Defaults to the code of the locale.
Locale KlyLocale The locale of every component below: texts, writing direction and the culture used to format dates and numbers. Defaults to the locale of an enclosing KlyApp , then Locale , then the one matching the current UI culture among Locales .
Overlays bool true Renders the KlyOverlayHost after the content, which shows the dialogs opened with IKlyOverlayService . Turn it off when the app places its own.
Overrides IReadOnlyDictionary<Type, ISlotOverrides> Class overrides for every component below, by component type. See KlyTheme .
SpatialNavigation bool false Turns on the remote control mode for TV screens (experimental, opt in): the arrow keys move focus to the nearest focusable element in that direction, the focus ring is thick and the sizes are larger ( data-kly-tv on the html element). See docs/platforms.md in the repository.
ToastDuration TimeSpan 00:00:05 How long a toast stays on screen.
Toaster bool true Renders the KlyToaster after the content. Turn it off when the app places its own.
Ui AppUi Per-instance class overrides of the slots of the app, see AppUi . They are merged after the theme and the Class parameter wins on the root slot.

Slots

Name Type Description
ChildContent RenderFragment The app: usually the body of the layout.

Ui slots

Ui takes a AppUi with one class string per slot, merged after the theme.

Slot Styles
Root Classes merged into the root slot of KlyApp , after the theme and the app configuration.