ontario-in-page-navigation-item
Use in-page navigation items to create the individual links inside an in-page navigation list.
This component is designed to be used as a child of ontario-in-page-navigation. It renders a single in-page anchor link and keeps the item styling consistent with the Ontario Design System.
If you need router-specific link markup, you can provide custom content through the default slot. When slot content is supplied, it takes precedence over the label and href props.
Usage guidance
Please refer to the Ontario Design System in-page navigation guidance for the latest documentation.
Configuration
Once the component package has been installed (see Ontario Design System Component Library for installation instructions), the item component can be added directly into the project's code, and can be customized by updating the properties outlined here. Pass both label and href for the standard pattern. The component warns if either value is missing.
When no default slot content is provided and either label or href is omitted, the component still renders an anchor for layout consistency and logs a console warning to help authors correct the configuration.
Examples
- Standard item Demonstrates the basic required configuration.
- HTML
- React
- Angular
<ontario-in-page-navigation-item label="Eligibility" href="#eligibility"></ontario-in-page-navigation-item>
<OntarioInPageNavigationItem label="Eligibility" href="#eligibility"></OntarioInPageNavigationItem>
<ontario-in-page-navigation-item [label]="'Eligibility'" [href]="'#eligibility'"></ontario-in-page-navigation-item>
- Item with long label Demonstrates wrapping behaviour.
- HTML
- React
- Angular
<ontario-in-page-navigation-item
label="What to include in your contract before completing your purchase"
href="#contract"
></ontario-in-page-navigation-item>
<OntarioInPageNavigationItem
label="What to include in your contract before completing your purchase"
href="#contract"
></OntarioInPageNavigationItem>
<ontario-in-page-navigation-item
[label]="'What to include in your contract before completing your purchase'"
[href]="'#contract'"
></ontario-in-page-navigation-item>
- Current (active) item Demonstrates the current section state.
<ontario-in-page-navigation-item
label="Eligibility"
href="#eligibility"
isCurrent="true"
></ontario-in-page-navigation-item>
This applies aria-current="location" to the rendered anchor.
- Slot override pattern When a router link is needed, use the default slot and supply the full anchor/link element.
<ontario-in-page-navigation-item>
<a class="ontario-in-page-navigation-item__link" href="#eligibility">Eligibility</a>
</ontario-in-page-navigation-item>
Accessibility guidance
- Match the item label text to the destination section heading text as closely as possible.
- Ensure the
hrefpoints to an in-page anchor that exists on the page. - Keep the item inside the in-page navigation host so list semantics and styling stay consistent.
If the default slot is used, the consumer is responsible for providing a valid anchor element, correct href behavior, and accessible link text.
Technical Note: SSR (Server-Side Rendering) Considerations
The Ontario In-Page Navigation Item component supports server-side rendering, with a few considerations:
- Pass
labelandhrefexplicitly for deterministic output. - Use a hash link such as
#eligibilityso the component can render the anchor correctly on first load.
SSR-safe example:
<ontario-in-page-navigation-item label="Eligibility" href="#eligibility"></ontario-in-page-navigation-item>
Overview
A single list item link used inside ontario-in-page-navigation.
For component guidance, see:
Properties
| Property | Attribute | Description | Type | Default |
|---|---|---|---|---|
href | href | In-page anchor target, for example #eligibility. | string | undefined | undefined |
isCurrent | is-current | Marks the current/active section. | boolean | undefined | false |
label | label | Link label for the in-page navigation item. | string | undefined | undefined |
language | language | Language used if localized text is required in the future. | "en" | "fr" | undefined | undefined |
Built with StencilJS