SkipLink
The first link of a page: hidden until it has the focus, it moves the focus to the main content.
On this page
Examples
Skip to content
Place it first in the layout and name the id of your main landmark (Target, "main" by default). A plain #main link would resolve against <base href> and load the home page from any other page, and the router only scrolls a hash link: a small handler in the Klyroo.UI JS moves the focus on the current page and leaves the address alone, in every render mode and in a web view. The target gets tabindex=-1 when it has none. The text is translated.
Click in this block and press Tab: the link appears in the top corner of the screen. Pressing Enter moves the focus to the content below, on this page, and leaves the address alone.
@* Put the link first in the page, before the header, and give the main landmark the id it names. Here a small block stands in for the main content. *@
<div class="flex w-full flex-col gap-3 text-sm">
<KlySkipLink Target="skip-link-example-main" data-testid="skip-link-example" />
<p class="text-(--klyroo-text-muted)">
Click in this block and press Tab: the link appears in the top corner of the screen. Pressing Enter moves the focus to the content below,
on this page, and leaves the address alone.
</p>
<div id="skip-link-example-main" class="rounded-md border border-(--klyroo-border) p-3 focus:outline-2 focus:outline-(--klyroo-primary-text)" data-testid="skip-link-example-target">
Main content
</div>
</div>API
KlySkipLink
First stop of the page for keyboard users: a link to the main content, visible when focused.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
Class |
string |
Classes added to the root element, merged last so they win over the theme. | |
Label |
string |
The text of the link. Defaults to the translated "Skip to content". | |
Target |
string |
"main" |
The id of the element that receives the focus, "main" by default. It gets tabindex="-1" when it has none. |
Ui |
SkipLinkUi |
Per-instance class overrides of the slots of the skip link, see SkipLinkUi . They are merged after the theme and the Class parameter wins on the root slot. |
Slots
| Name | Type | Description |
|---|---|---|
ChildContent |
RenderFragment |
Replaces Label . |
Ui slots
Ui takes a SkipLinkUi with one class string per slot, merged after the theme.
| Slot | Styles |
|---|---|
Root |
Classes merged into the root slot of KlySkipLink , after the theme and the app configuration. |