diff --git a/aspnetcore/blazor/forms/input-components.md b/aspnetcore/blazor/forms/input-components.md index 8dcc271dc3d3..ac3ca69c6257 100644 --- a/aspnetcore/blazor/forms/input-components.md +++ b/aspnetcore/blazor/forms/input-components.md @@ -458,27 +458,34 @@ The validation summary displays the friendly name when the field's value is inva > The Production Date field must be a date. - +The component can be used to display property names from metadata attributes. The [`[Display]` attribute](xref:System.ComponentModel.DataAnnotations.DisplayAttribute) on the model class property is supported: + +```csharp +[Required, Display(Name = "Production Date")] +public DateTime ProductionDate { get; set; } +``` + +[`[DisplayName]` attribute](xref:System.ComponentModel.DisplayNameAttribute) is also supported: + +```csharp +[Required, DisplayName("Production Date")] +public DateTime ProductionDate { get; set; } +``` + +Between the two approaches, the `[Display]` attribute is recommended, which makes additional properties available. The `[Display]` attribute also enables assigning a resource type for localization. When both attributes are present, `[Display]` takes precedence over `[DisplayName]`. If neither attribute is present, the component falls back to the property name itself. + +Use the `DisplayName` component in labels or table headers: + +```razor + +``` :::moniker-end