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

Button with Icon Only does not render well when used with badge #15848

Closed
Joebeurg opened this issue Jun 14, 2024 · 1 comment
Closed

Button with Icon Only does not render well when used with badge #15848

Joebeurg opened this issue Jun 14, 2024 · 1 comment
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible

Comments

@Joebeurg
Copy link

Describe the bug

When using the Button component while only specifying an icon and a badge, it does not render well, this is cause by a class that gets appended to the button .p-button-icon-only which has a fixed width width: 2.5rem;.

.p-button.p-button-icon-only {
    width: 2.5rem;
    padding: 0.5rem 0;
}

When a label is provided the badge inside the button is rendered correctly.

This is the button with the issue:

<p-button (click)="sidebarVisible = true" icon="pi pi-align-justify" severity="secondary"
              badge="150" badgeClass="p-badge-warning"/>

image

This is the button with label:

<p-button label="Menu" (click)="sidebarVisible = true" icon="pi pi-align-justify" severity="secondary"
              badge="150" badgeClass="p-badge-warning"/>

image

Environment

OS: Windows 11

Reproducer

No response

Angular version

18.0.1

PrimeNG version

17.18.0

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

20.14.0

Browser(s)

Microsoft Edge; Version 125.0.2535.92 (Official build) (64-bit)

Steps to reproduce the behavior

No response

Expected behavior

No response

@Joebeurg Joebeurg added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jun 14, 2024
@mjlux
Copy link

mjlux commented Jun 19, 2024

As correctly mentioned the .p-button-icon-only class interferes with the badge attribute of the p-button component.
You can circumvent this issue by using a different setup of your p-button implementation

<p-button severity="secondary">
  <i class="pi pi-align-justify"></i>
  <p-badge value="150" />
</p-button>

Hope this helps

@Joebeurg Joebeurg closed this as not planned Won't fix, can't repro, duplicate, stale Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible
Projects
None yet
Development

No branches or pull requests

2 participants