Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MudListItem: SecondaryText Feature #8921

Merged
merged 3 commits into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<MudListItem Text="Sent" Icon="@Icons.Material.Filled.Send" />
<MudListItem Text="Drafts" Disabled="true" IconColor="Color.Info" Icon="@Icons.Material.Filled.Drafts" />
<MudDivider />
<MudListItem Text="Trash" />
<MudListItem Text="Spam" />
<MudListItem Text="Trash" SecondaryText="Removed e-mails" />
<MudListItem Text="Spam" SecondaryText="E-mails from common providers" />
</MudList>
</MudPaper>
5 changes: 5 additions & 0 deletions src/MudBlazor/Components/List/MudListItem.razor
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
else
{
@Text
@if (!string.IsNullOrEmpty(SecondaryText))
{
<br />
<MudText Class="mud-list-item-secondary-text" Typo="Typo.subtitle2">@SecondaryText</MudText>
Copy link
Contributor

@Yomodo Yomodo May 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I normally use mt-n or pt-n instead of br/>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not about margin or padding. Need to be sure secondary text placed on new line. In some situations text and secondary text show in one line. And there is no guarantee that MudText never be changed.

}
}
</MudText>
</div>
Expand Down
7 changes: 7 additions & 0 deletions src/MudBlazor/Components/List/MudListItem.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ public MudListItem()
[Category(CategoryTypes.List.Behavior)]
public string? Text { get; set; }

/// <summary>
/// The secondary text to display
/// </summary>
[Parameter]
[Category(CategoryTypes.List.Behavior)]
public string? SecondaryText { get; set; }

[Parameter]
[Category(CategoryTypes.List.Selecting)]
public T? Value { get; set; }
Expand Down
5 changes: 5 additions & 0 deletions src/MudBlazor/Styles/components/_list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,8 @@
padding-inline-end: unset;
}
}

.mud-list-item-secondary-text {
font-weight: 500;
color: var(--mud-palette-text-secondary);
}
Loading