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

feat(button): expose button part #2470

Merged
merged 9 commits into from
Apr 26, 2023
5 changes: 5 additions & 0 deletions .changeset/plenty-clouds-exist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@patternfly/elements": minor
---

`<pf-button>`: expose `button` part for styling the internal button element
bennypowers marked this conversation as resolved.
Show resolved Hide resolved
7 changes: 4 additions & 3 deletions elements/pf-button/BaseButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import styles from './BaseButton.css';

/**
* Base button class
*
* @csspart button - Internal button element
* @csspart icon - Container for the icon slot
* @slot icon
* Contains the button's icon or state indicator, e.g. a spinner.
Expand Down Expand Up @@ -57,10 +57,11 @@ export abstract class BaseButton extends LitElement {
override render() {
const { hasIcon } = this;
return html`
<button type="${ifDefined(this.type)}"
<button aria-label="${ifDefined(this.label)}"
class="${classMap({ hasIcon })}"
part="button"
type="${ifDefined(this.type)}"
value="${ifDefined(this.value)}"
aria-label="${ifDefined(this.label)}"
@click="${this.#onClick}"
?disabled="${this.disabled || this.#internals.formDisabled}">
<slot id="icon" part="icon" aria-hidden="true" name="icon">${this.renderDefaultIcon()}</slot>
Expand Down