Skip to content
Page PageAnchors

PageAnchors

A list of in-page anchors, typically the table of contents in a right column.

On this page

Examples

Anchors

Plain anchors: an address-based active state would mark every fragment link as current.

Installation

Add the package to your project.

Theming

Override the CSS variables.

Releases

Follow the changelog.

Razor
<div class="grid w-full gap-6 sm:grid-cols-[12rem_1fr]">
    <KlyPageAnchors Links="_anchors" data-testid="anchors" />
    <div role="region" aria-label="Page content" tabindex="0" class="max-h-48 overflow-y-auto rounded-lg focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--klyroo-primary-text) border border-(--klyroo-border) bg-(--klyroo-bg) p-4 text-sm text-(--klyroo-text-muted)">
        <section id="anchor-install" class="min-h-40"><p class="font-medium text-(--klyroo-text-highlighted)">Installation</p><p>Add the package to your project.</p></section>
        <section id="anchor-theming" class="min-h-40"><p class="font-medium text-(--klyroo-text-highlighted)">Theming</p><p>Override the CSS variables.</p></section>
        <section id="anchor-release" class="min-h-40"><p class="font-medium text-(--klyroo-text-highlighted)">Releases</p><p>Follow the changelog.</p></section>
    </div>
</div>

@code {
    private readonly PageLinkItem[] _anchors =
    [
        new("Installation", "#anchor-install") { Icon = "download" },
        new("Theming", "#anchor-theming") { Icon = "pencil" },
        new("Releases", "#anchor-release") { Icon = "star" },
        new("GitHub", "https://github.com/") { Icon = "code", Target = KlyLinkTarget.Blank },
    ];
}

API

KlyPageAnchors

List of in-page anchor links.

Parameters

Name Type Description
Class string Classes added to the root element, merged last so they win over the theme.
Links IReadOnlyList<PageLinkItem> The anchors: Href is typically a fragment such as #installation . A fragment is rendered with the path and query of the current page: in a document with a base element a bare fragment would resolve against the base address and leave the page. Pass aria-label to rename the navigation.
Ui PageAnchorsUi Per-instance class overrides of the slots of the page anchors, see PageAnchorsUi . They are merged after the theme and the Class parameter wins on the root slot.

Ui slots

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

Slot Styles
Root Classes merged into the root slot of KlyPageAnchors , after the theme and the app configuration.
List Classes merged into the list slot of KlyPageAnchors , after the theme and the app configuration.
Item Classes merged into the item slot of KlyPageAnchors , after the theme and the app configuration.
Link Classes merged into the link slot of KlyPageAnchors , after the theme and the app configuration.
Leading Classes merged into the leading slot of KlyPageAnchors , after the theme and the app configuration.
LeadingIcon Classes merged into the leadingIcon slot of KlyPageAnchors , after the theme and the app configuration.
Label Classes merged into the label slot of KlyPageAnchors , after the theme and the app configuration.
ExternalIcon Classes merged into the externalIcon slot of KlyPageAnchors , after the theme and the app configuration.