Skip to main content
twblazor
Home
  • Get started
  • Tailwind with Blazor
  • Why twblazor?
  • Theme
  • Class Merge
    • Configuring localization
    • RTL Provider
  • Breadcrumb
  • Card
  • Carousel
  • Collapse
  • Context Menu
  • Drawer
  • Footer
  • Menu
  • Navbar
  • On This Page
  • Separator
  • Sidebar
  • Stepper
  • Tabs
  • Tree List
  • Container
  • Flex
  • Grid
  • Text
  • Link
  • Button
  • Form
    • AutocompleteNew
    • Checkbox
    • Color Picker
    • Date Picker
    • Date Range Picker
    • Datetime Picker
    • Datetime Range Picker
    • File Upload
    • Input GroupNew
    • NumericNew
    • Masked InputNew
    • Radio Button
    • Range SliderNew
    • RatingNew
    • Select
    • Slider
    • Switch
    • Tag InputNew
    • Text EditorNew
    • Textfield
    • Time Picker
    • Time Range Picker
  • Toggle
  • Toggle Group
  • Alert
  • Avatar
  • Badge
  • Chip
  • Empty
  • Icon
  • Popover
  • Progress
  • Skeleton
  • Spinner
  • Tooltip
  • Data Table
  • SpreadsheetNew
  • Column Filter Editor
  • Pagination
  • Pick List
  • Barcode
  • QR Code
  • Calendar
  • Table
  • Attachment
  • Overview
    • Bar
    • Bullet
    • Column
    • Dot Plot
    • Dumbbell
    • Icon
    • Lollipop
    • Radial Bar
    • Range
    • Word Cloud
    • Area
    • Bump
    • Bump Area
    • Candlestick
    • Gantt
    • Horizon
    • Line
    • Slope
    • Small Multiples
    • Stream Graph
    • Funnel
    • Gauge
    • Marimekko
    • Nightingale
    • Pie
    • Treemap
    • Waffle
    • Waterfall
    • Circular Treemap
    • Convex Treemap
    • Dendrogram
    • Sunburst
    • Barcode
    • Beeswarm
    • Box Plot
    • Density Plot
    • Histogram
    • Radial Histogram
    • Ridgeline
    • Strip Plot
    • Violin Plot
    • Categorical Scatter
    • Contour
    • Hexagonal Binning
    • Quadrant
    • Scatter
    • Heatmap
    • Matrix
    • Parallel Coordinates
    • Radar
    • Arc Diagram
    • Chord Diagram
    • Flowchart
    • Network Diagram
    • Sankey
    • Euler Diagram
    • Venn Diagram
  • Bubble
  • Marker
  • Message
  • 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 7 November 2026

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
twblazor

The Tailwind CSS component library for Blazor. Accessible, themeable and MIT licensed.

Discord (opens in a new tab) GitHub(opens in a new tab)

Get started

  • Install guide
  • Theming
  • Class merging
  • Localization

Guides

  • Tailwind CSS with Blazor
  • Why twblazor?
  • Right to left
  • AI agents and skills

Resources

  • API documentation (opens in a new tab)
  • llms.txt (opens in a new tab)
  • MIT License (opens in a new tab)

Community

  • Contributing (opens in a new tab)
  • Code of conduct (opens in a new tab)
  • Report an issue (opens in a new tab)

twblazor is and always will be free and open source.

An unhandled error has occurred. Reload