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

Forms

TwButton

TwButton is a Blazor button component. Use Variant, Color, StartIcon, EndIcon, Href, Disabled and IconButton, or group buttons horizontally or vertically.

Last updated 20 October 2026

Buttons

Usage of the button component is simple, you can use it to trigger actions. Below are some common actions:
RAZOR
<TwButtonGroup>
    <TwButton Label="@($"Clicked {ClickCount} times")" Color="Color.Accent" StartIcon="Icon.Chat_Square_Dots" OnClick="HandleClick" />
    <TwButton AriaLabel="Submit Type" Label="Submit" Color="Color.Primary" StartIcon="Icon.Mailbox" OnClick="@(() => { /* your action */ })" Type="submit" />
</TwButtonGroup>
CSHARP
@code {
    public int ClickCount { get; set; } = 0;
    private void HandleClick() => ClickCount++;
}

Icon buttons

The button component can also be used with icons only:
RAZOR
<TwButtonGroup>
    <TwIcon Icon="@(darkMode ? Icon.Sun : Icon.Moon)" AriaLabel="Set light mode" OnClick="ToggleMode" Color="@(darkMode ? Color.Dark : Color.Light)" ButtonVariant="ButtonVariant.Filled" />
</TwButtonGroup>
CSHARP
@code {
    private bool darkMode { get; set; }
    private void ToggleMode() => darkMode = !darkMode;
}

Tooltips

Set Tooltip to show a short description when the button is hovered or keyboard-focused. It renders a role="tooltip" element linked to the button with aria-describedby, stays visible while the pointer moves onto it, and can be dismissed with Escape. A tooltip only supplements the accessible name, so icon-only buttons still need an AriaLabel. The same Tooltip property works on an icon button (TwIcon with OnClick).
Save your changes This cannot be undone Open the help centre
RAZOR
<TwButtonGroup>
    <TwButton Label="Save" Color="Color.Primary" StartIcon="Icon.Save" Tooltip="Save your changes" />
    <TwButton Label="Delete" Variant="ButtonVariant.Outlined" Color="Color.Danger" Tooltip="This cannot be undone" />
    <TwIcon Icon="Icon.Question_Circle" AriaLabel="Help" Tooltip="Open the help centre" OnClick="@(() => { /* your action */ })" />
</TwButtonGroup>

Buttons variants & colors

There are multiple different button variants.
RAZOR
<div class="flex flex-col gap-4">
    @foreach (Color c in Enum.GetValues<Color>())
    {
        <div class="@(c == Color.Light ? "grid grid-cols-2 gap-2 sm:flex sm:flex-wrap -mx-3 rounded-lg bg-gray-900 dark:bg-transparent p-3" : "grid grid-cols-2 gap-2 sm:flex sm:flex-wrap")">
            <TwButton Label="@c.ToString()" Color="@c" Variant="@ButtonVariant.Filled" />
            <TwButton Label="@c.ToString()" Color="@c" Variant="@ButtonVariant.Outlined" />
            <TwButton Label="@c.ToString()" Color="@c" Variant="@ButtonVariant.Text" />
            <TwButton Label="@c.ToString()" Color="@c" Variant="@ButtonVariant.Elevated" />
        </div>
    }
</div>

Buttons with icons

Buttons can include icons at the start or end for better visual communication:
RAZOR
<div class="flex flex-wrap gap-2">
    <TwButton Label="Download" StartIcon="Icon.Download" Variant="ButtonVariant.Filled" Color="Color.Primary" />
    <TwButton Label="Next" EndIcon="Icon.Arrow_Right" Variant="ButtonVariant.Filled" Color="Color.Success" />
    <TwButton Label="Delete" StartIcon="Icon.Trash" Variant="ButtonVariant.Outlined" Color="Color.Danger" />
    <TwButton Label="Settings" StartIcon="Icon.Gear" Variant="ButtonVariant.Filled" Color="Color.Primary" />
</div>

All colors

Buttons support all color themes from the color palette:
RAZOR
<div class="flex flex-wrap gap-2">
    @foreach (Color c in Enum.GetValues<Color>())
    {
        <TwButton Label="@c.ToString()" Color="@c" />
    }
</div>

Button states

Buttons can be disabled or set to readonly mode:
RAZOR
<div class="flex flex-wrap gap-2">
    <TwButton Label="Filled Disabled" Variant="ButtonVariant.Filled" Color="Color.Primary" Disabled />
    <TwButton Label="Outlined Disabled" Variant="ButtonVariant.Outlined" Color="Color.Primary" Disabled />
    <TwButton Label="Text Disabled" Variant="ButtonVariant.Text" Color="Color.Primary" Disabled />
    <TwButton Label="Readonly Button" Color="Color.Success" Readonly />
</div>

Basic button groups

Group related buttons together with consistent spacing.
RAZOR
<TwButtonGroup>
    <TwButton Label="First" Color="Color.Primary" />
    <TwButton Label="Second" Color="Color.Primary" />
    <TwButton Label="Third" Color="Color.Primary" />
</TwButtonGroup>

Vertical button groups

Stack buttons vertically.
RAZOR
<TwButtonGroup Vertical>
    <TwButton Label="Top" Color="Color.Success" StartIcon="Icon.Arrow_Up" />
    <TwButton Label="Middle" Color="Color.Success" />
    <TwButton Label="Bottom" Color="Color.Success" EndIcon="Icon.Arrow_Down" />
</TwButtonGroup>

Full width button groups

Make buttons fill the container width equally.
RAZOR
<TwButtonGroup FullWidth>
    <TwButton Label="Option 1" Color="Color.Accent" Variant="ButtonVariant.Outlined" />
    <TwButton Label="Option 2" Color="Color.Accent" Variant="ButtonVariant.Outlined" />
    <TwButton Label="Option 3" Color="Color.Accent" Variant="ButtonVariant.Outlined" />
</TwButtonGroup>

Keyboard navigation

A button is a native button, or a native link when it has an Href.
Key What it does
Tab Moves focus to the button. A read-only button stays focusable and is announced as unavailable.
Enter or Space Activates the button.
Escape Hides the button's tooltip, if it has one.

Theme configuration

Styling is controlled by TwBlazorTheme.Components (a TwButtonTheme), 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.

Inherited from TwButton - this component reuses that theme rather than defining its own.

Property Type Controls
ButtonRounded Rounded?
ButtonShadow Shadow?
DefaultVariant ButtonVariant?
ButtonUppercase bool
Uppercase string
Base string
Padding string
DensePadding string
IconButton string
Typography string
IconTypography string
DisabledCursor string
ReadonlyCursor string
DefaultCursor string
DisabledFilled string
DisabledOutlined string
DisabledText string

Full reference: TwButtonTheme on the API docs.

On this page

  • Buttons
  • Icon buttons
  • Tooltips
  • Buttons variants & colors
  • Buttons with icons
  • All colors
  • Button states
  • Basic button groups
  • Vertical button groups
  • Full width button groups
  • 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