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

TwNavbar

TwNavbar is a responsive Blazor navbar with BrandContent, NavigationContent and ActionsContent slots, data-driven NavigationItems and keyboard support.

Last updated 18 October 2026

Structured navbar

TwNavbar provides BrandContent, NavigationContent, and ActionsContent slots for hand-written markup. Responsive collapse is enabled by default: below the lg breakpoint the links and actions fold away behind a toggle at the end of the bar. Opening it drops a full-width menu under the bar, on the same surface, with each link as a row tall enough to tap and the actions set apart underneath, centered in a row. A menu taller than the screen scrolls on its own. Shrink the preview to see it.
Acme
Home Products Pricing
RAZOR
<TwNavbar>
    <BrandContent>
        <a href="/" class="flex items-center gap-2 text-gray-900 dark:text-white font-bold tracking-tight">
            <TwIcon Icon="Icon.Lightning_Charge_Fill" />
            Acme
        </a>
    </BrandContent>
    <NavigationContent>
        <a href="/" class="px-3 py-2 rounded-md text-sm font-medium text-gray-600 hover:text-gray-900 hover:bg-gray-100 dark:text-gray-300 dark:hover:text-white dark:hover:bg-white/10 transition-colors">Home</a>
        <a href="#" class="px-3 py-2 rounded-md text-sm font-medium text-gray-600 hover:text-gray-900 hover:bg-gray-100 dark:text-gray-300 dark:hover:text-white dark:hover:bg-white/10 transition-colors">Products</a>
        <a href="#" class="px-3 py-2 rounded-md text-sm font-medium text-gray-600 hover:text-gray-900 hover:bg-gray-100 dark:text-gray-300 dark:hover:text-white dark:hover:bg-white/10 transition-colors">Pricing</a>
    </NavigationContent>
    <ActionsContent>
        <TwButton Label="Sign in" Variant="ButtonVariant.Text" Color="Color.Dark" />
        <TwButton Label="Get started" Variant="ButtonVariant.Filled" Color="Color.Accent" />
    </ActionsContent>
</TwNavbar>

Data-driven links

Pass NavigationItems instead of hand-written NavigationContent to render links (with optional icons) from a List<NavigationItem>, and mark one active with IsActive. Other slots such as BrandContent and ActionsContent still work alongside it.
Acme
HomeProductsPricing
RAZOR
<TwNavbar NavigationItems="@_navigationItems">
    <BrandContent>
        <a href="/" class="flex items-center gap-2 text-gray-900 dark:text-white font-bold tracking-tight">
            <TwIcon Icon="Icon.Lightning_Charge_Fill" />
            Acme
        </a>
    </BrandContent>
    <ActionsContent>
        <TwButton Label="Sign in" Variant="ButtonVariant.Text" Color="Color.Dark" />
    </ActionsContent>
</TwNavbar>
CSHARP
@code {
    private readonly List<NavigationItem> _navigationItems =
    [
        new() { Label = "Home", Href = "/", Icon = Icon.House_Door_Fill, IsActive = true },
        new() { Label = "Products", Href = "#", Icon = Icon.Box_Seam_Fill },
        new() { Label = "Pricing", Href = "#", Icon = Icon.Tag_Fill }
    ];
}

Disable responsive collapse

Set DisableResponsiveCollapse to keep the navigation and actions slots always visible with no mobile toggle - useful when a parent layout, such as TwSidebar, already owns a mobile toggle. TwSidebar sets this on its embedded navbar for exactly that reason.
Acme
Home Products
RAZOR
<TwNavbar DisableResponsiveCollapse>
    <BrandContent>
        <a href="/" class="flex items-center gap-2 text-gray-900 dark:text-white font-bold tracking-tight">
            <TwIcon Icon="Icon.Lightning_Charge_Fill" />
            Acme
        </a>
    </BrandContent>
    <NavigationContent>
        <a href="/" class="px-3 py-2 rounded-md text-sm font-medium text-gray-600 hover:text-gray-900 hover:bg-gray-100 dark:text-gray-300 dark:hover:text-white dark:hover:bg-white/10 transition-colors">Home</a>
        <a href="#" class="px-3 py-2 rounded-md text-sm font-medium text-gray-600 hover:text-gray-900 hover:bg-gray-100 dark:text-gray-300 dark:hover:text-white dark:hover:bg-white/10 transition-colors">Products</a>
    </NavigationContent>
    <ActionsContent>
        <TwButton Label="Sign in" Variant="ButtonVariant.Text" Color="Color.Dark" />
    </ActionsContent>
</TwNavbar>

Keyboard navigation

The navbar is a navigation landmark holding ordinary links. On a narrow screen the links sit behind a menu button.
Key What it does
Tab Moves to the next link or button.
Enter Follows the focused link.
Enter or Space On the menu button: opens or closes the menu.

Theme configuration

Styling is controlled by TwBlazorTheme.Components (a TwSidebarTheme), 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
SkipLink string
DrawerCloseButton string
MobileOverlay string
MobileClosed string
MobileOpen string
NavigationList string
NavbarFixedInset string
NavbarNavigationResponsive string
NavbarNavigationExpanded string
Navbar string
NavbarContent string
NavbarBrand string
NavbarNavigation string
NavbarActions string
NavbarActionsCollapsible string
NavbarToggle string
NavbarToggleIcon string
NavbarLink string
NavbarLinkCollapsible string
NavbarLinkActive string
NavbarMobileMenu string
Sidebar string
MainContent string
MainContentRoot string
NavigationItemBase string
NavigationItemActive string
NavigationItemCurrent string
NavigationItemParent string
NavigationItemIcon string
NavigationItemContent string
NavigationDropdownContainer string
NavigationItemActiveLevelDeep string
NavigationDropdownContainerDeep string
NavigationGroupRailDeep string
NavigationItemToggleLabel string
NavigationItemToggleIcon string
Header string
Search string
SearchIcon string
SearchInput string
SearchInputVariant InputVariant?

Full reference: TwSidebarTheme on the API docs.

On this page

  • Structured navbar
  • Data-driven links
  • Disable responsive collapse
  • 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