Class TwCard
- Namespace
- TwBlazor.Components
- Assembly
- TwBlazor.dll
Represents a card component that provides a contained surface for grouping related content.
public class TwCard : TwBlazorComponentBase, IComponent, IHandleEvent, IHandleAfterRender, ITwComponent
- Inheritance
-
TwCard
- Implements
- Inherited Members
Remarks
The TwCard component uses the Surface Container theme tokens by default
(bg-gray-100 dark:bg-gray-800) with On Surface text colours.
It supports an optional title, optional header/footer sections,
and respects the global shadow and rounded corner configuration.
Constructors
TwCard()
public TwCard()
Properties
Bordered
Gets or sets whether the card has a visible border.
[Parameter]
public bool Bordered { get; set; }
Property Value
Remarks
When true, applies the Outline Variant token (border-gray-200 dark:border-gray-700).
Default is true.
ChildContent
Gets or sets the main content of the card.
[Parameter]
public RenderFragment? ChildContent { get; set; }
Property Value
FooterContent
Gets or sets content rendered in a footer at the bottom of the card, such as actions or a price.
[Parameter]
public RenderFragment? FooterContent { get; set; }
Property Value
Remarks
The footer stays at the bottom of the card when cards in the same grid row have different amounts of content.
HeaderContent
Gets or sets custom header content rendered below the title.
[Parameter]
public RenderFragment? HeaderContent { get; set; }
Property Value
ImageAlt
Gets or sets the image's alternative text.
[Parameter]
public string? ImageAlt { get; set; }
Property Value
Remarks
Describe what the image shows when it adds information. Leave it empty when the image is decorative or repeats the card's text, so screen readers skip it.
ImageClass
Gets or sets extra classes for the image, merged over the theme's, for example to change its aspect ratio.
[Parameter]
public string? ImageClass { get; set; }
Property Value
ImageSrc
Gets or sets the URL of an image shown edge to edge at the top of the card.
[Parameter]
public string? ImageSrc { get; set; }
Property Value
MediaContent
Gets or sets content for the media area at the top of the card. It renders after the image, so with
ImageSrc it can be positioned over the image (the media area is relative), such as a
badge. Without an image it is the media itself, such as a video.
[Parameter]
public RenderFragment? MediaContent { get; set; }
Property Value
Title
Gets or sets the title text displayed at the top of the card.
[Parameter]
public string? Title { get; set; }
Property Value
Remarks
When provided, renders as a heading inside the card header area. If HeaderContent is also provided, the title is rendered before it.
TitleLevel
Gets or sets the heading level (1-6) rendered for Title, so the card's heading can fit correctly into the surrounding page's heading outline instead of always being an <h3> regardless of context. Defaults to 3.
[Parameter]
public int TitleLevel { get; set; }
Property Value
Methods
BuildRenderTree(RenderTreeBuilder)
Renders the component to the supplied RenderTreeBuilder.
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
__builderRenderTreeBuilder