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

TwCard

TwCard is a Blazor card component for grouping content. Set Title, HeaderContent and Bordered, or lay cards out in a responsive grid.

Last updated 20 October 2026

Basic card

A card with a Title and some content. The title renders as an h3; set TitleLevel to fit it into your page's heading outline.

Account overview

Your account is in good standing. You have 3 active subscriptions, and your next payment is due on 1 November.

RAZOR
<TwCard Title="Account overview">
    <p class="text-sm leading-6 text-gray-600 dark:text-gray-300">
        Your account is in good standing. You have <span class="font-semibold text-gray-900 dark:text-white">3</span> active subscriptions, and your next payment is due on 1 November.
    </p>
</TwCard>

Card with an image

Set ImageSrc to show an image edge to edge across the top of the card. Describe the image in ImageAlt when it adds information; leave it empty when it is decorative, as here, so screen readers skip it. Images load lazily.

Designing for dark mode

2 Oct 2026 · 6 min read

Why dark themes need their own colour choices, not just inverted ones.

AJ Alice Johnson

Accessible forms in Blazor

9 Oct 2026 · 8 min read

Labels, errors and focus order that work for everyone.

BO Ben Okafor
RAZOR
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2">
    @foreach (var article in _articles)
    {
        <TwCard Title="@article.Title" ImageSrc="@article.Image" ImageAlt="">
            <HeaderContent>
                <p class="text-xs text-gray-600 dark:text-gray-300">@article.Date · @article.ReadTime read</p>
            </HeaderContent>
            <ChildContent>
                <p class="text-sm leading-6 text-gray-600 dark:text-gray-300">@article.Summary</p>
            </ChildContent>
            <FooterContent>
                <TwAvatar Name="@article.Author" Size="AvatarSize.Small" />
                <span class="text-sm font-medium text-gray-900 dark:text-white">@article.Author</span>
            </FooterContent>
        </TwCard>
    }
</div>
CSHARP
@code {
    private sealed record Article(string Title, string Summary, string Date, string ReadTime, string Author, string Image);
    
    private readonly Article[] _articles =
    [
        new("Designing for dark mode", "Why dark themes need their own colour choices, not just inverted ones.", "2 Oct 2026", "6 min", "Alice Johnson", "_content/TwBlazor.Docs/images/placeholder-1.webp"),
        new("Accessible forms in Blazor", "Labels, errors and focus order that work for everyone.", "9 Oct 2026", "8 min", "Ben Okafor", "_content/TwBlazor.Docs/images/placeholder-2.webp")
    ];
}

Product cards

Combine MediaContent and FooterContent for a shop. Without ImageSrc, MediaContent is the media itself, here an icon tile with an offer badge; with an image it sits over it. The footer stays at the bottom so prices and buttons line up across a row, and each button names its product for screen readers.

Your basket is empty.

Wireless headphones

Noise cancelling, 30 hour battery

£149.00

In stock

Save £30

Smartwatch

Heart rate, GPS and sleep tracking

£169.00

In stock

Bluetooth speaker

Waterproof, 12 hour battery

£59.99

Only 3 left

New

Mechanical keyboard

Hot swappable switches, UK layout

£89.00

In stock

RAZOR
<div class="flex flex-col gap-4">
    <p class="flex items-center gap-2 text-sm text-gray-600 dark:text-gray-300" role="status">
        <TwIcon Icon="Icon.Basket" />
        @_basketMessage
    </p>
    <div class="grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-4">
        @foreach (var product in _products)
        {
            <TwCard Title="@product.Name">
                <MediaContent>
                    <div class="flex aspect-4/3 items-center justify-center bg-purple-50 text-purple-600 dark:bg-purple-400/10 dark:text-purple-300">
                        <TwIcon Icon="@product.Icon" Class="text-6xl" />
                    </div>
                    @if (product.Offer is not null)
                    {
                        <TwChip Label="@product.Offer" Size="ChipSize.Small" Color="Color.Accent" Class="absolute top-3 start-3" />
                    }
                </MediaContent>
                <HeaderContent>
                    <p class="text-sm text-gray-600 dark:text-gray-300">@product.Detail</p>
                </HeaderContent>
                <FooterContent>
                    <div class="me-auto">
                        <p class="text-lg font-semibold tabular-nums text-gray-900 dark:text-white">@product.Price</p>
                        <p class="text-xs text-gray-600 dark:text-gray-300">@product.Stock</p>
                    </div>
                    <TwButton Color="Color.Primary" StartIcon="Icon.Plus_Lg" AriaLabel="@($"Add {product.Name} to basket")" OnClick="@(() => AddToBasket(product))">Add</TwButton>
                </FooterContent>
            </TwCard>
        }
    </div>
</div>
CSHARP
@code {
    private sealed record Product(string Name, string Detail, string Price, string Stock, Icon Icon, string? Offer = null);
    
    private readonly Product[] _products =
    [
        new("Wireless headphones", "Noise cancelling, 30 hour battery", "£149.00", "In stock", Icon.Headphones),
        new("Smartwatch", "Heart rate, GPS and sleep tracking", "£169.00", "In stock", Icon.Smartwatch, "Save £30"),
        new("Bluetooth speaker", "Waterproof, 12 hour battery", "£59.99", "Only 3 left", Icon.Speaker),
        new("Mechanical keyboard", "Hot swappable switches, UK layout", "£89.00", "In stock", Icon.Keyboard, "New")
    ];
    
    private int _basketCount;
    private string _basketMessage = "Your basket is empty.";
    
    private void AddToBasket(Product product)
    {
        _basketCount++;
        _basketMessage = $"{product.Name} added. {_basketCount} {(_basketCount == 1 ? "item" : "items")} in your basket.";
    }
}

Card with a footer

Use FooterContent for actions or metadata. It renders below a divider at the bottom of the card; put the main action last.

Invoice #1042

Amount
£2,340.00
Issued
14 October 2026
Status
Paid
RAZOR
<TwCard Title="Invoice #1042">
    <ChildContent>
        <dl class="space-y-3 text-sm">
            <div class="flex items-center justify-between gap-4">
                <dt class="text-gray-600 dark:text-gray-300">Amount</dt>
                <dd class="font-semibold tabular-nums text-gray-900 dark:text-white">£2,340.00</dd>
            </div>
            <div class="flex items-center justify-between gap-4">
                <dt class="text-gray-600 dark:text-gray-300">Issued</dt>
                <dd class="text-gray-900 dark:text-white">14 October 2026</dd>
            </div>
            <div class="flex items-center justify-between gap-4">
                <dt class="text-gray-600 dark:text-gray-300">Status</dt>
                <dd><TwChip Label="Paid" StartIcon="Icon.Check_Circle_Fill" Size="ChipSize.Small" Color="Color.Success" /></dd>
            </div>
        </dl>
    </ChildContent>
    <FooterContent>
        <div class="ms-auto flex flex-wrap gap-2">
            <TwButton Variant="ButtonVariant.Text" Color="Color.Primary" StartIcon="Icon.Download">Download PDF</TwButton>
            <TwButton Variant="ButtonVariant.Filled" Color="Color.Primary">View invoice</TwButton>
        </div>
    </FooterContent>
</TwCard>

Card without border

Set Bordered="false" to remove the border. The card then stands out from a tinted page through its background and shadow alone.

Weekly summary

You closed 14 tickets this week, 4 more than last week.

RAZOR
<div class="rounded-lg bg-gray-100 p-6 dark:bg-gray-900">
    <TwCard Title="Weekly summary" Bordered="false">
        <p class="text-sm leading-6 text-gray-600 dark:text-gray-300">You closed 14 tickets this week, 4 more than last week.</p>
    </TwCard>
</div>

Card with header content

Use HeaderContent for extra header elements below the title, such as a short description.

Team members

Manage who can access this workspace.

  • AJ

    Alice Johnson

    alice@example.co.uk · Admin

    Active
  • BO

    Ben Okafor

    ben@example.co.uk · Editor

    Active
  • CW

    Chloe Williams

    chloe@example.co.uk · Viewer

    Invited
RAZOR
<TwCard Title="Team members">
    <HeaderContent>
        <p class="text-sm text-gray-600 dark:text-gray-300">Manage who can access this workspace.</p>
    </HeaderContent>
    <ChildContent>
        <ul class="divide-y divide-gray-200 dark:divide-gray-700">
            @foreach (var member in _members)
            {
                <li class="flex items-center gap-3 py-3">
                    <TwAvatar Name="@member.Name" Size="AvatarSize.Small" />
                    <div class="min-w-0 flex-1">
                        <p class="text-sm font-medium wrap-break-word text-gray-900 dark:text-white">@member.Name</p>
                        <p class="text-xs wrap-break-word text-gray-600 dark:text-gray-300">@member.Email · @member.Role</p>
                    </div>
                    <TwChip Label="@(member.Active ? "Active" : "Invited")" Size="ChipSize.Small" Color="@(member.Active ? Color.Success : Color.Warning)" Variant="@(member.Active ? ButtonVariant.Filled : ButtonVariant.Outlined)" />
                </li>
            }
        </ul>
    </ChildContent>
</TwCard>
CSHARP
@code {
    private sealed record TeamMember(string Name, string Email, string Role, bool Active);
    
    private readonly TeamMember[] _members =
    [
        new("Alice Johnson", "alice@example.co.uk", "Admin", true),
        new("Ben Okafor", "ben@example.co.uk", "Editor", true),
        new("Chloe Williams", "chloe@example.co.uk", "Viewer", false)
    ];
}

Content-only card

Leave out Title for a card that is just content, such as a profile summary.
PP

Priya Patel

Product designer, London

RAZOR
<TwCard>
    <div class="flex flex-wrap items-center gap-4">
        <TwAvatar Name="Priya Patel" Color="Color.Primary" Size="AvatarSize.Large" />
        <div class="min-w-0 flex-1">
            <p class="font-semibold text-gray-900 dark:text-white">Priya Patel</p>
            <p class="text-sm text-gray-600 dark:text-gray-300">Product designer, London</p>
        </div>
        <TwButton Variant="ButtonVariant.Outlined" Color="Color.Primary" StartIcon="Icon.Envelope" AriaLabel="Message Priya Patel">Message</TwButton>
    </div>
</TwCard>

Card grid

Cards work well in a responsive grid. These stack on small screens and sit three across from the sm breakpoint.

Revenue

£24,500

12.5% up on last month

Orders

1,234

8.2% up on last month

Customers

567

3.1% down on last month

RAZOR
<div class="grid grid-cols-1 gap-4 sm:grid-cols-3">
    <TwCard Title="Revenue">
        <div>
            <p class="text-2xl font-semibold tabular-nums text-gray-900 dark:text-white">£24,500</p>
            <p class="mt-1 flex items-center gap-1 text-sm text-green-700 dark:text-green-400">
                <TwIcon Icon="Icon.Arrow_Up" />
                12.5% up on last month
            </p>
        </div>
    </TwCard>
    <TwCard Title="Orders">
        <div>
            <p class="text-2xl font-semibold tabular-nums text-gray-900 dark:text-white">1,234</p>
            <p class="mt-1 flex items-center gap-1 text-sm text-green-700 dark:text-green-400">
                <TwIcon Icon="Icon.Arrow_Up" />
                8.2% up on last month
            </p>
        </div>
    </TwCard>
    <TwCard Title="Customers">
        <div>
            <p class="text-2xl font-semibold tabular-nums text-gray-900 dark:text-white">567</p>
            <p class="mt-1 flex items-center gap-1 text-sm text-red-700 dark:text-red-400">
                <TwIcon Icon="Icon.Arrow_Down" />
                3.1% down on last month
            </p>
        </div>
    </TwCard>
</div>

Keyboard navigation

This component is not interactive, so it has no keyboard controls of its own and is not a Tab stop. Anything interactive you place inside it keeps its own keyboard behaviour.

Theme configuration

Styling is controlled by TwBlazorTheme.Components (a TwCardTheme), 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
Bordered string
Title string
Content string
Header string
Media string
Image string
Footer string

Full reference: TwCardTheme on the API docs.

On this page

  • Basic card
  • Card with an image
  • Product cards
  • Card with a footer
  • Card without border
  • Card with header content
  • Content-only card
  • Card grid
  • 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