Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DxButtonBase.ChildContent Property

Specifies Button content.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
[Parameter]
public RenderFragment<RenderFragment> ChildContent { get; set; }

#Property Value

Type Description
RenderFragment<RenderFragment>

Content markup.

#Remarks

The ChildContent component parameter can store custom component content that does not belong to other component’s RenderFragment properties as shown below:

Razor
<DxButton RenderStyle="ButtonRenderStyle.Info"
          Click="@Like"
          IconCssClass="btn-icon-like"
          Text="Like">
    <ChildContent>
            @context
            <span class="ms-1">@likes</span>
    <ChildContent>
</DxButton>
@* ... *@
@code {
    int likes;

    void Like(MouseEventArgs args) {
        likes++;
    }
    protected override void OnInitialized() {
        likes = 1;
    }
}

Button Custom Content

In this example, the Button renders custom content (like counter) next to the default content specified in the button’s properties (text and icon). Use the @context parameter to specify where the default content should be rendered.

Note

Buttons are rendered as a button HTML element. According to HTML specification a button must not contain interactive elements or elements with the tabindex attribute specified.

You can omit the <ChildContent> tag and specify the markup directly in the <DxButton> tag:

Razor
    <DxButton RenderStyle="ButtonRenderStyle.Info"
              Click="@Like"
              IconCssClass="btn-icon-like"
              @* ... *@
              Text="Like">
        @context
        <span class="ms-1">@likes</span>
    </DxButton>
    @* ... *@
@code {
    int likes;

    void Like(MouseEventArgs args) {
        likes++;
    }
    protected override void OnInitialized() {
        likes = 1;
    }
}

Run Demo: Button — Custom Content

See Also