CardBody

in namespace DotVVM.Bootstrap5.Controls

Renders a body of a Card component.

Usage & Scenarios

Renders a text content inside the Card control.

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

Sample 1: Basic CardBody

Use the TitleText, SubtitleText and Text properties to provide two levels of title and a text content for the card.

<bs:Card>
  <bs:CardBody TitleText="Main title" SubtitleText="Secondary title" Text="Body of the card" />
</bs:Card>

Sample 2: Templated CardBody

If you need to provide a custom content in the card body, place the content inside the control.

Bootstrap recommends the following CSS classes to be used in the card body templates:

  • h1, ..., h6 elements should have card-title or card-subtitle CSS classes.
  • p and other text elements should have card-text CSS class.
  • a elements should have card-link CSS class.

You can set AddAppropriateCardClassesToContent property to true which makes the control to add the CSS classes automatically based on the rules mentioned above.

<bs:Card FooterText="Card Footer">
  <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}" TextBinding="{value: _this}" />

</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 AddAppropriateCardClassesToContent Boolean Gets or sets whether appropriate classes (card-text, card-link, ...) should be added to inner elements. Can be used only when the Content property is used.
attribute
inner element
static value
bindable
default
False
property icon Content List<DotvvmControl> Gets or sets the content placed inside the control.
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 the text inside the control.
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