Skip to main content

DxGrid.CssClass Property

Assign a CSS class to the Grid.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

[DefaultValue(null)]
[Parameter]
public string CssClass { get; set; }

Property Value

Type Default Description
String null

CSS class names delimited by spaces.

Remarks

The CssClass property allows you to customize the Grid’s appearance. The assigned CSS class is added to the Grid’s root element.

The Grid consists of Bootstrap elements (card, table, and so on) and standard HTML elements (div, input, and so on). You can use the CssClass property to apply CSS classes to any of these elements. Refer to the following articles for more information:

The following code snippet applies a CSS class to the card element:

@inject WeatherForecastService ForecastService

<style>
    .my-style{
        font-style: italic;
        color: darkgray;
    }
</style>

<DxGrid Data="@Data" CssClass="my-style">
    <Columns>
        <DxGridDataColumn FieldName="Date" DisplayFormat="D" />
        <DxGridDataColumn FieldName="TemperatureC" Caption="@("Temp. (\x2103)")" Width="120px" />
        <DxGridDataColumn FieldName="TemperatureF" Caption="@("Temp. (\x2109)")" Width="120px" />
        <DxGridDataColumn FieldName="Forecast" />
        <DxGridDataColumn FieldName="CloudCover" />
    </Columns>
</DxGrid>

@code {
    object Data { get; set; }

    protected override void OnInitialized() {
        Data = ForecastService.GetForecast();
    }
}

For more information on how to apply CSS classes to DevExpress Blazor components, refer to the following help topic: CSS Classes.

If your custom CSS ruleset includes only one class selector (.my-style in the code sample above), some property declarations can be ignored. DevExpress themes can apply predefined CSS rules that are more specific and have higher priority than a single-selector rule. Make your rule more specific to increase the priority of your ruleset. See the following help topic for an example: Apply Styles to Components. For more information about how a browser calculates rule priority, refer to the following topic: Understanding the cascade.

You can use the !important flag to override other CSS rules. However, note that this flag modifies the standard behavior of the cascade, which can make troubleshooting CSS issues quite challenging, particularly in large stylesheets.

Implements

See Also