Options
Placement matters, especially on mobile and tablet. See Page layout before you build.
How the list is generated
The component creates the list from your page's headings and updates it as they change. It skips headings that are hidden, empty, inside a <nys-accordion>, or marked with data-nys-onthispage-ignore.
Scope
Headings inside <main> are tracked by default. Set scope to a CSS selector, like #guide, to track a different container. If it matches more than one element, the first is used.
Apply for a permit
Eligibility
You must be a New York State resident aged 18 or older.
How to apply
Complete the online form and upload your supporting documents.
<nys-onthispage scope="#guide"></nys-onthispage>
<article id="guide">
<h2>Eligibility</h2>
<h2>How to apply</h2>
</article>
Heading level
h2 headings are tracked by default. Set headingTracker to h3 through h6 to track a different level. h1 is never tracked.
This is a <h3> tag
This is another <h3> tag
This is also a <h3> tag
This is a <h4> tag
<nys-onthispage headingTracker="h3"></nys-onthispage>
Excluding a heading
Add data-nys-onthispage-ignore to a heading, to leave it out of the navigation.
<nys-onthispage></nys-onthispage>
<main>
<h1>Eligibility</h1>
<div>
<h2 data-nys-onthispage-ignore>Related links</h2>
<div>
<h2>External resources</h2>
</div>
</div>
<h2>How to apply</h2>
</main>
Page layout
On desktop, place the component in a side column (for left-to-right languages):
- Left by default.
- Right if the site has vertical navigation. Keep it on the right on every page, even when the vertical navigation isn't shown.
Don't hide it on small screens. Put each side navigation in its own <aside> and place the asides before <main> so they sit above the content. Add nys-desktop:nys-order-last to the "on this page" <aside> to move it to the right on desktop.
On mobile and tablet, the navigation stacks above the content. On desktop, it moves to a side column. Use the order utility classes to set its visual position.
<h1>Welcome to the Empire State of Mind</h1>
<div class="nys-grid-container">
<div class="nys-grid-row nys-grid-gap">
<aside class="nys-desktop:nys-grid-col-2 nys-order-first">
<nys-verticalnav heading="NYS Info" headingLevel="h2" >
<ul>
<li><a href="/">Home</a></li>
<li><a href="/explore">About</a></li>
<li>
<h3>Season Explore</h3>
<ul>
<li><a href="">Spring</a></li>
<li><a href="">Summer</a></li>
<li><a href="">Fall</a></li>
<li><a href="">Winter</a></li>
</ul>
</li>
</ul>
</nys-verticalnav>
</aside>
<aside class="nys-desktop:nys-grid-col-2 nys-order-first nys-desktop:nys-order-last">
<nys-onthispage offset="24" scope="#onthispage-layout"></nys-onthispage>
</aside>
<main id="onthispage-layout" class="nys-desktop:nys-grid-col-fill">
<h4>Apple picking season</h4>
<p>Orchards from the Hudson Valley to the Finger Lakes are open.</p>
<h4>Pizza by the slice</h4>
<p>Fold it. Do not eat it with a fork!</p>
<h4>Road trip to Niagara Falls</h4>
<p>Pack snacks and enjoy one of the most beautiful natural wonders in the world.</p>
</main>
</div>
</div>
Sticky behavior
The component is already sticky. Place it directly inside the <aside>, without a wrapper <div>, which has no extra height for it to stick in. You don't need to add position: sticky.
Disable Sticky
The navigation is sticky by default and stays at the top of the viewport as the user scrolls. This only applies on viewports 480px or wider. Set disableSticky to let it scroll with the page.
Eligibility
You must be a New York State resident aged 18 or older.
How to apply
Complete the online form and upload your supporting documents.
<nys-onthispage disableSticky></nys-onthispage>
Offset
offset is the distance in pixels from the top of the viewport to the trigger line. A heading becomes active when its top edge reaches this line. It also sets scroll-margin-top on tracked headings and top on the sticky navigation. The default is 80.
Increase offset if the page has a fixed header, so headings don't end up behind it after a click.
Custom heading
Set heading to change the title above the list. The default is "On this page".
Eligibility
You must be a New York State resident aged 18 or older.
How to apply
Complete the online form and upload your supporting documents.
What happens next
We review applications within 10 business days.
<nys-onthispage heading="In this guide"></nys-onthispage>
Heading ids
Links point to the heading id. If a heading has none, one is generated from its text, like #how-to-apply. Duplicates get a number, like #how-to-apply-2. Ids you set are never changed.
<h2 id="eligibility">Eligibility</h2>
<h2>How to apply</h2>
<h2>How to apply</h2>
Updating the URL
Set hashBehavior to control what happens to the URL when a link is clicked.
none: leaves the URL alone (default)
hash: adds a history entry for each click
replace: updates the URL without adding a history entry
<nys-onthispage hashBehavior="replace"></nys-onthispage>
Links scroll smoothly by default. Set disableSmoothScroll to jump straight to the section. Users with prefers-reduced-motion enabled always get instant scrolling.
<nys-onthispage disableSmoothScroll></nys-onthispage>
This component has no dependencies on other NYSDS components.
Edit this page on GitHub (Permissions required)
Last updated: December 3, 2026