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

Charts

TwChart

TwChart is the Blazor chart container for over fifty chart types. It adds a title, loading state and shared options. Accessible and script-free.

Last updated 8 November 2026

Basic usage

TwChart is the container: it frames a chart with a title, a description and a loading state. Place one chart component inside it and pass the data. Every chart supplies its own legend, tooltips on hover and keyboard focus, and a table view of the same data.
Revenue by regionThousands of pounds, last quarter
0100200300400500
0100200300400500
North2024 3602025 420
South2024 2902025 310
East2024 2402025 275
West2024 3302025 380
NorthSouthEastWest
RAZOR
<TwChart Title="Revenue by region" Description="Thousands of pounds, last quarter">
    <TwColumnChart Categories="@_regions" Series="@_yearly" />
</TwChart>
CSHARP
@code {
    private readonly string[] _regions = ["North", "South", "East", "West"];
    
    private readonly ChartSeries[] _revenue = [new("Revenue", [420, 310, 275, 380])];
    
    private readonly ChartSeries[] _yearly =
    [
        new("2024", [360, 290, 240, 330]),
        new("2025", [420, 310, 275, 380])
    ];
}

Choosing a chart

Start from what the reader needs to see, then pick the chart. Each chart has its own page with examples of every option.
To show Use
A comparison between categories
BarColumnLollipopDot plotDumbbellRangeBulletIconRadial barWord cloud
A change over time
LineAreaSlopeBumpSmall multiplesCandlestickGanttStream graphBump areaHorizon
Parts of a whole
PieWaffleTreemapFunnelNightingaleWaterfallGaugeMarimekko
A hierarchy
SunburstCircular treemapConvex treemapDendrogram
How values are distributed
HistogramBox plotStrip plotViolin plotBeeswarmDensity plotRidgelineBarcodeRadial histogram
How two values relate
ScatterQuadrantHexbinContourCategorical scatter
Several variables at once
RadarParallel coordinatesHeatmapMatrix
Flows and connections
SankeyChord diagramArc diagramNetwork diagramFlowchart
How sets overlap
Venn diagramEuler diagram

Title and description

Title names the chart, on screen and for assistive technology. Use Description for the unit or the period, so the axis does not have to carry it. Both are optional; without a title, give the chart an AriaLabel.
Revenue by regionThousands of pounds, last quarter
NorthSouthEastWest
NorthSouthEastWest
NorthRevenue 420
SouthRevenue 310
EastRevenue 275
WestRevenue 380
0100200300400500
RAZOR
<TwChart Title="Revenue by region" Description="Thousands of pounds, last quarter">
    <TwBarChart Categories="@_regions" Series="@_revenue" />
</TwChart>

Height

Height sets how tall the plot is: ChartHeight.Small, Medium (the default) or Large. Set it on the container, or on a chart to override the container. The width always follows the space available. Radial charts are square, and Height sets how wide the square may grow.
Revenue by region
0100200300400500
0100200300400500
NorthRevenue 420
SouthRevenue 310
EastRevenue 275
WestRevenue 380
NorthSouthEastWest
RAZOR
<TwChart Title="Revenue by region" Height="ChartHeight.Small">
    <TwColumnChart Categories="@_regions" Series="@_revenue" />
</TwChart>

Formatting values

Every chart takes ValueFormat, any .NET numeric format string, or ValueFormatter, a function, for full control. The format applies to the axis, tooltips, value labels and table view alike, in the current culture.
Revenue by region
¤0¤100¤200¤300¤400¤500
¤0¤100¤200¤300¤400¤500
¤420
¤310
¤275
¤380
NorthRevenue ¤420
SouthRevenue ¤310
EastRevenue ¤275
WestRevenue ¤380
NorthSouthEastWest
RAZOR
<TwChart Title="Revenue by region">
    <TwColumnChart Categories="@_regions" Series="@_revenue" ValueFormat="C0" ShowValues="true" />
</TwChart>
Revenue by region
£0k£100k£200k£300k£400k£500k
£0k£100k£200k£300k£400k£500k
£420k
£310k
£275k
£380k
NorthRevenue £420k
SouthRevenue £310k
EastRevenue £275k
WestRevenue £380k
NorthSouthEastWest
RAZOR
<TwChart Title="Revenue by region">
    <TwColumnChart Categories="@_regions" Series="@_revenue" ValueFormatter="FormatThousands" ShowValues="true" />
</TwChart>
CSHARP
@code {
    private static string FormatThousands(double value) => $"£{value:0}k";
}

Legend

A chart with two or more series shows a legend; a single series needs none, because the title names it. Each entry is a button that hides or shows its series, and a series keeps its color while others are hidden. Set InteractiveLegend to false for a plain legend, or ShowLegend to false to remove it.
Monthly visitorsThousands
  • Organic
  • Paid
  • Referral
020406080
020406080
JanOrganic 42Paid 30Referral 12
FebOrganic 48Paid 34Referral 15
MarOrganic 55Paid 31Referral 21
AprOrganic 61Paid 45Referral 19
MayOrganic 58Paid 52Referral 26
JunOrganic 70Paid 49Referral 33
JanFebMarAprMayJun
RAZOR
<TwChart Title="Monthly visitors" Description="Thousands">
    <TwLineChart Categories="@_months" Series="@_visitors" InteractiveLegend="false" />
</TwChart>

Table view

"View as table" swaps the plot for a table of the same data, and "View as chart" swaps it back. The table is the accessible alternative to the plot, so only set ShowTableToggle to false when the same data is available elsewhere on the page. TableViewLabel, ChartViewLabel and TableLabel change the wording.
Revenue by region and year
0100200300400500
0100200300400500
North2024 3602025 420
South2024 2902025 310
East2024 2402025 275
West2024 3302025 380
NorthSouthEastWest
RAZOR
<TwChart Title="Revenue by region and year">
    <TwColumnChart Categories="@_regions" Series="@_yearly" CategoryHeader="Region" TableViewLabel="Show the numbers" ChartViewLabel="Show the chart" />
</TwChart>

Loading and empty states

Set Loading on the container to show a spinner with a "Loading chart" message while data is fetched; screen readers announce it. A chart with no data shows an empty state with its EmptyText instead of an empty set of axes. Both keep the chart's height.
Loading
Loading...

Loading chart

No data

Nothing to show for this period

RAZOR
<div class="grid gap-8 md:grid-cols-2">
    <TwChart Title="Loading" Height="ChartHeight.Small" Loading="true" />
    <TwChart Title="No data" Height="ChartHeight.Small">
        <TwColumnChart EmptyText="Nothing to show for this period" />
    </TwChart>
</div>

Accessibility

The chart is a group named by the container's Title. Each data point is announced with its values. The plot is a single tab stop: tab into it, then use the arrow, Home and End keys to move between data points. On a touch screen, tap a data point to show its tooltip. A slice, wedge, ring, ribbon, tile or filled curve responds anywhere on its shape. Focus shows the same tooltip as hover, and Esc dismisses it. The table view presents the same data without the plot. Text never takes a series color, direction and status are always named as well as colored, and colors are assigned in a fixed order chosen so neighboring series stay distinguishable for color-blind readers. Keep to eight series or fewer: there are eight colors, and a ninth series would reuse the last.

Adding your own chart type

Every chart is a small class that describes what to draw. Derive from TwCategoryChartBase (categories and series), TwValueChartBase (labelled values) or TwChartBase, and add marks with the ChartSceneBuilder. Positions are percentages of the plot area. The legend, tooltips, keyboard support, table view and theming come from the base class, so a new chart needs no markup or styles of its own.
Onboarding progressPercent complete
ProfileBillingTeam invites
ProfileBillingTeam invites
ProfileComplete 100
BillingComplete 60
Team invitesComplete 25
CSHARP
/// <summary>
/// A custom chart: each value is drawn as a filled track out of 100.
/// </summary>
public class CompletionChart : TwValueChartBase
{
    protected override void BuildMarks(ChartSceneBuilder builder)
    {
        builder.Horizontal = true;
        var band = new ChartBand(Data.Count);
        var color = ChartColor.Series(0);
        builder.BandAxis([.. Data.Select(item => item.Label)], band);

        for (var i = 0; i < Data.Count; i++)
        {
            var filled = Math.Clamp(Data[i].Value, 0, 100);
            builder.Bar(band.Center(i), 6, 0, 100, ChartColor.Track, ChartCorner.All, gap: false);
            builder.Bar(band.Center(i), 6, 0, filled, color, ChartCorner.All, gap: false);
            builder.BandDatum(band.Center(i), band.Step, Data[i].Label,
                [new ChartDatumRow(effectiveValueHeader, FormatValue(Data[i].Value), color)]);
        }
    }
}

Keyboard navigation

The plot is a single Tab stop. Each data point is announced with its series and value as focus reaches it, and the table view presents the same data without the plot.
Key What it does
Tab Moves focus into the plot, onto the data point last visited.
Arrow Right or Arrow Down Moves to the next data point.
Arrow Left or Arrow Up Moves to the previous data point.
Home or End Moves to the first or last data point.
Escape Hides the tooltip of the focused data point.
Enter or Space On a legend item: shows or hides that series. On the table button: switches between the chart and its data table.

Theme configuration

Styling is controlled by TwBlazorTheme.Components (a TwChartTheme), 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
Container string
Header string
Title string
Description string
Body string
Chart string
Toolbar string
Legend string
LegendItem string
LegendButton string
LegendItemHidden string
LegendSwatch string
TableToggle string
AxisTitle string
XAxisTitle string
Frame string
FrameWithYAxis string
YAxis string
AxisSizer string
Tick string
YTick string
XAxis string
XTick string
Plot string
Small string
Medium string
Large string
Square string
SquareSmall string
SquareMedium string
SquareLarge string
Canvas string
Rect string
RoundedTop string
RoundedBottom string
RoundedLeft string
RoundedRight string
RoundedAll string
SurfaceRing string
Dot string
Glyph string
Text string
TextMuted string
TextPrimary string
TextInverse string
TextStrong string
TextLarge string
TextTruncate string
FillNone string
StrokeHairline string
StrokeNormal string
StrokeThick string
SurfaceStroke string
HitWrapper string
HitWrapperShaped string
HitShape string
Hit string
HitHighlight string
Crosshair string
TooltipTitle string
TooltipRow string
TooltipKey string
TooltipLabel string
TooltipValue string
TableRowHeader string
Series IReadOnlyList`1
Positive TwChartColor
Negative TwChartColor
Total TwChartColor
Sequential TwChartColor
Track TwChartColor
Grid TwChartColor
Axis TwChartColor
Ink TwChartColor

Full reference: TwChartTheme on the API docs.

On this page

  • Basic usage
  • Choosing a chart
  • Title and description
  • Height
  • Formatting values
  • Legend
  • Table view
  • Loading and empty states
  • Accessibility
  • Adding your own chart type
  • 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