Skip to content
Navigation Tabs

Tabs

WAI-ARIA tabs with automatic activation.

On this page

Examples

Pill

Make changes to your account.

Selected: account

Razor
<div class="w-full max-w-md">
    <KlyTabs Items="Items" @bind-Value="_tab" AriaLabel="Account settings" />
    <p class="mt-2 text-sm text-(--klyroo-text-muted)" data-testid="tab-state">Selected: @(_tab ?? "account")</p>
</div>

@code {
    private string? _tab;

    private static readonly KlyTabItem[] Items =
    [
        new("Account") { Value = "account", Content = @<p class="p-4 text-sm">Make changes to your account.</p> },
        new("Password") { Value = "password", Content = @<p class="p-4 text-sm">Change your password.</p> },
        new("Danger zone") { Value = "danger", Disabled = true },
    ];
}

Project overview.

Razor
<div class="w-full max-w-md">
    <KlyTabs Variant="TabsVariant.Link" AriaLabel="Project" Items="Items" />
</div>

@code {
    private static readonly KlyTabItem[] Items =
    [
        new("Overview") { Content = @<p class="py-4 text-sm">Project overview.</p> },
        new("Activity") { Content = @<p class="py-4 text-sm">Recent activity.</p> },
        new("Settings") { Content = @<p class="py-4 text-sm">Project settings.</p> },
    ];
}

API

KlyTabs

Tabs that switch between content panels, following the WAI-ARIA tabs pattern. Selection happens in the browser.

Parameters

Name Type Default Description
AriaLabel string Accessible name of the tab list.
Class string Classes added to the root element, merged last so they win over the theme.
Color KlyColor "primary" Semantic color of the tabs: a built-in KlyColor or the name of a color you defined. When not set, Color applies, else the default of the component. Values: primary, secondary, success, info, warning, error, neutral.
Items (required) IReadOnlyList<KlyTabItem> The tabs, as KlyTabItem .
Orientation KlyOrientation KlyOrientation.Horizontal Direction of the layout: Horizontal or Vertical . Values: Horizontal, Vertical.
Ui TabsUi Per-instance class overrides of the slots of the tabs, see TabsUi . They are merged after the theme and the Class parameter wins on the root slot.
Value (@bind-Value) string Value of the selected tab. Defaults to the first enabled one.
Variant TabsVariant TabsVariant.Pill Look of the tabs: Pill or Link . Values: Pill, Link.

Ui slots

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

Slot Styles
Root Classes merged into the root slot of KlyTabs , after the theme and the app configuration.
List Classes merged into the list slot of KlyTabs , after the theme and the app configuration.
Trigger Classes merged into the trigger slot of KlyTabs , after the theme and the app configuration.
Icon Classes merged into the icon slot of KlyTabs , after the theme and the app configuration.
Label Classes merged into the label slot of KlyTabs , after the theme and the app configuration.
Content Classes merged into the content slot of KlyTabs , after the theme and the app configuration.