Skip to main content
twblazor
Home
  • Get started
  • Tailwind with Blazor
  • Why twblazor?
  • Theme
  • Class Merge
    • Configuring localization
    • RTL Provider
  • Breadcrumb
  • Card
  • Carousel
  • Collapse
  • Footer
  • MenuNew
  • Navbar
  • On This PageNew
  • Sidebar
  • Stepper
  • Tabs
  • Tree List
  • Button
  • Checkbox
  • Color Picker
    • Date
    • Date Range
    • Datetime
    • Datetime Range
    • Time
    • Time Range
  • File Upload
  • NumericNew
  • Radio Button
  • RatingNew
  • Select
  • Slider
  • Switch
  • Textfield
  • Alert
  • Avatar
  • Chip
  • Icon
  • Progress
  • Skeleton
  • Spinner
  • TooltipNew
  • Data Table
  • Pagination
  • Pick List
  • BarcodeNew
  • QR CodeNew
  • CalendarNew
  • Table
  • Overview
  • Area
  • Bar
  • Box Plot
  • Bullet
  • Bump
  • Candlestick
  • Column
  • Dot Plot
  • Dumbbell
  • Funnel
  • Gantt
  • Gauge
  • Heatmap
  • Histogram
  • Icon
  • Line
  • Lollipop
  • Matrix
  • Nightingale
  • Parallel Coordinates
  • Pie
  • Quadrant
  • Radar
  • Radial Bar
  • Range
  • Scatter
  • Slope
  • Small Multiples
  • Strip Plot
  • Treemap
  • Waffle
  • Waterfall
  • Arc Diagram
  • Barcode
  • Beeswarm
  • Bump Area
  • Categorical Scatter
  • Chord Diagram
  • Circular Treemap
  • Contour
  • Convex Treemap
  • Density Plot
  • Dendrogram
  • Euler Diagram
  • Flowchart
  • Hexagonal Binning
  • Horizon
  • Marimekko
  • Network Diagram
  • Radial Histogram
  • Ridgeline
  • Sankey
  • Stream Graph
  • Sunburst
  • Venn Diagram
  • Violin Plot
  • Word Cloud
  • Dialog Service
  • Toast Service
API DocumentationAI Agents & Skills
Home Get Started

Layout

TwOnThisPage

TwOnThisPage is a Blazor table of contents component: an On this page list of section links that highlights the section being read as you scroll.

Last updated 18 October 2026

Please be aware this component is new, may have bugs and/or be subject to change. Please report any bugs at https://github.com/twblazor/twblazor/issues.

Basic usage

Give TwOnThisPage a list of OnThisPageItems, each pairing the Id of an element on the page with the text of its link. The link to the section being read is highlighted as the page scrolls. The example lists this page's own sections, so scroll the page to see it follow along. It is the same component as the "On this page" list beside every page of these docs.

On this page

  • Basic usage
  • Link paths
  • Title and heading level
  • Hidden title
  • Fixed headers
RAZOR
<TwOnThisPage Items="@_sections" BasePath="/on-this-page" Class="max-w-xs" />
CSHARP
@code {
    private readonly List<OnThisPageItem> _sections =
    [
        new("basic-usage", "Basic usage"),
        new("link-paths", "Link paths"),
        new("title-and-heading-level", "Title and heading level"),
        new("hidden-title", "Hidden title"),
        new("fixed-headers", "Fixed headers")
    ];
}

Link paths

Every Blazor app has a <base href>, which makes a bare #section link point at the site root instead of the current page. Set BasePath to the current page's path so each link becomes /your-page#section.

On this page

  • Basic usage
  • Link paths
  • Title and heading level
  • Hidden title
  • Fixed headers
RAZOR
<TwOnThisPage Items="@_sections" BasePath="/on-this-page" Class="max-w-xs" />

Title and heading level

The heading defaults to "On this page", translated into the app's language. Set Title to change it, and HeadingLevel so it fits the page's heading outline. The navigation landmark is named after the heading, so screen reader users can find it in their list of landmarks.

Contents

  • Basic usage
  • Link paths
  • Title and heading level
  • Hidden title
  • Fixed headers
RAZOR
<TwOnThisPage Items="@_sections" BasePath="/on-this-page" Title="Contents" HeadingLevel="3" Class="max-w-xs" />

Hidden title

Set HideTitle to leave the visible heading out, for example when the list sits under a heading of your own. The landmark keeps its name through aria-label, so it is still announced.
  • Basic usage
  • Link paths
  • Title and heading level
  • Hidden title
  • Fixed headers
RAZOR
<TwOnThisPage Items="@_sections" BasePath="/on-this-page" HideTitle Class="max-w-xs" />

Fixed headers

A section counts as the one being read once its top passes a line 140 pixels below the top of the viewport. Raise Offset when a fixed header covers more of the page than that, or lower it for a page with nothing fixed at the top.

On this page

  • Basic usage
  • Link paths
  • Title and heading level
  • Hidden title
  • Fixed headers
RAZOR
<TwOnThisPage Items="@_sections" BasePath="/on-this-page" Offset="240" Class="max-w-xs" />

Keyboard navigation

The list is a navigation landmark holding ordinary links. The link to the section being read is announced as the current location.
Key What it does
Tab or Shift+ plus Tab Moves to the next or previous link.
Enter Jumps to the focused link's section.

Theme configuration

Styling is controlled by TwBlazorTheme.Components (a TwOnThisPageTheme), configured via the AddTwBlazor() options callback described on the Get Started page. Every property is a set of Tailwind classes, so changes are picked up by your own Tailwind build.
Property Type Controls
Title string
List string
Link string
LinkCurrent string

Full reference: TwOnThisPageTheme on the API docs.

On this page

  • Basic usage
  • Link paths
  • Title and heading level
  • Hidden title
  • Fixed headers
  • Keyboard navigation
  • Theme configuration
Discord (opens in a new tab) • GitHub (opens in a new tab) • Documentation (opens in a new tab) • MIT License (opens in a new tab) • llms.txt (opens in a new tab)

twblazor is and always will be free and open source.

An unhandled error has occurred. Reload