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:

https://getbootstrap.com/docs/5.2/components/card

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
property icon BorderColor BootstrapColor Gets or sets the card border color.
attribute
inner element
static value
bindable
default
null
property icon Color CardColor Gets or sets the card color. Both the background and text color css classes are set.
attribute
inner element
static value
bindable
default
null
property icon Content List<ICardItem> Gets or sets a custom template for the card content. Cannot be combined with a `Text` property.
attribute
inner element
static value
bindable
default
null
property icon FooterTemplate ITemplate Gets or sets a custom template for card footer. Cannot be combined with a `FooterText` property.
attribute
inner element
static value
bindable
default
null
property icon FooterText String Gets or sets a plain text for card footer. Cannot be combined with a `FooterTemplate` property.
attribute
inner element
static value
bindable
default
null
property icon HeaderTemplate ITemplate Gets or sets a custom template for card header. Cannot be combined with a `HeaderText` property.
attribute
inner element
static value
bindable
default
null
property icon HeaderText String Gets or sets a plain text for card header. Cannot be combined with a `HeaderTemplate` property.
attribute
inner element
static value
bindable
default
null
property icon SubtitleText String Gets or sets the control subtitle text. H6 tag is used.
attribute
inner element
static value
bindable
default
null
property icon Text String Gets or sets a plain text for card content. Cannot be combined with any custom content inside the card.
attribute
inner element
static value
bindable
default
null
property icon TitleText String Gets or sets the control title text. H5 tag is used.
attribute
inner element
static value
bindable
default
null
property icon Visible Boolean Gets or sets whether the control is visible. When set to false, `style="display: none"` will be added to this control.
attribute
inner element
static value
bindable
default
True

HTML produced by the control