Card
in namespace DotVVM.Bootstrap5.Controls
Renders a bootstrap card component
Usage & Scenarios
Renders the Bootstrap card with flexible content options. The card can contain one of more content items:
- CardBody for text content.
- CardImage for image or other media content.
- CardListGroup for lists of items.
Sample 1: Basic Card
The contents of the card are just placed inside the control element.
You can use HeaderText
or HeaderTemplate
, and FooterText
or FooterTemplate
properties to specify contents of the card header and footer bar.
Use SubtitleText
or SubtitleTemplate
properties to specify subtitle of the card.
To provide a text content, use Text
property or CardBody control.
<bs:Card FooterText="Card Footer">
<HeaderTemplate>
<h1>Header</h1>
</HeaderTemplate>
<bs:CardBody Text="Body of the card" />
</bs:Card>
<bs:Card HeaderText="Header" TitleText="Title"
SubtitleText="Subtitle" Text="Text"
FooterText="Footer" />
<bs:Card HeaderText="{value: HeaderText}" TitleText="{value: TitleText}" SubtitleText="{value: SubtitleText}" Text="{value: Text}" FooterText="{value: FooterText}" />
Sample 2: Card with images and lists
The card can contain images or lists. Use any combination of CardBody, CardImage and CardListGroup controls.
<bs:Card>
<bs:CardImage ImageUrl="~/images/LA.jpg" ToolTip="Card Image">
<bs:CardBody style="color:aliceblue;">
<h1>Overlaid body</h1>
<p>
Another text
</p>
<p>Some buttons</p>
<bs:Button Click="{command: DoSomething()}" Text="Button" Type="Danger" />
</bs:CardBody>
</bs:CardImage>
<bs:CardListGroup DataSource="{value: Texts}" ItemText="{value: _this}" />
</bs:Card>
public class ViewModel : DotvvmViewModelBase
{
public string[] Texts { get; } = new[] { "red", "green", "blue" };
public void DoSomething()
{
}
}
Sample 3: Card colors
The card component can use different backgrounds and border colors with Color
and BorderColor
properties.
<bs:Card Color="Danger" BorderColor="Warning">
<bs:CardBody TitleText="Title" Text="Text" />
</bs:Card>
<bs:Card Color="Light" BorderColor="Dark">
<bs:CardBody TitleText="Title" Text="Text" />
</bs:Card>
<bs:Card Color="Success" BorderColor="Light">
<bs:CardBody TitleText="Title" Text="Text" />
</bs:Card>
public class ViewModel : DotvvmViewModelBase
{
public string[] Texts { get; } = new[] { "red", "green", "blue" };
public void DoSomething()
{
}
}
Properties
Name | Type | Description | Notes | Default Value | |
---|---|---|---|---|---|
BorderColor | BootstrapColor | Gets or sets the card border color. |
attribute
static value
bindable
|
null | |
ClientIDMode | ClientIDMode | Gets or sets the client ID generation algorithm. |
attribute
static value
|
Static | |
Color | CardColor | Gets or sets the card color. Both the background and text color css classes are set. |
attribute
static value
bindable
|
null | |
Content | List<ICardItem> | Gets or sets a custom template for the card content. Cannot be combined with a `Text` property. |
inner element
static value
default
|
null | |
DataContext | Object | Gets or sets a data context for the control and its children. All value and command bindings are evaluated in context of this value. The DataContext is null in client-side templates. |
attribute
bindable
|
null | |
FooterTemplate | ITemplate | Gets or sets a custom template for card footer. Cannot be combined with a `FooterText` property. |
inner element
static value
|
null | |
FooterText | String | Gets or sets a plain text for card footer. Cannot be combined with a `FooterTemplate` property. |
attribute
static value
bindable
|
null | |
HeaderTemplate | ITemplate | Gets or sets a custom template for card header. Cannot be combined with a `HeaderText` property. |
inner element
static value
|
null | |
HeaderText | String | Gets or sets a plain text for card header. Cannot be combined with a `HeaderTemplate` property. |
attribute
static value
bindable
|
null | |
ID | String | Gets or sets the control client ID within its naming container. |
attribute
static value
bindable
|
null | |
IncludeInPage | Boolean | Gets or sets whether the control is included in the DOM of the page. |
attribute
bindable
|
True | |
SubtitleText | String | Gets or sets the control subtitle text. H6 tag is used. |
attribute
static value
bindable
|
null | |
Text | String | Gets or sets a plain text for card content. Cannot be combined with any custom content inside the card. |
attribute
static value
bindable
|
null | |
TitleText | String | Gets or sets the control title text. H5 tag is used. |
attribute
static value
bindable
|
null | |
Visible | Boolean | Gets or sets whether the control is visible. When set to false, `style="display: none"` will be added to this control. |
attribute
static value
bindable
|
True |