Skip to content

Commit c7556fc

Browse files
authored
uui button: ability to set title for button or A-tag (#1199)
* ability to parse title * only set title if it has a value * only set title if it has a value
1 parent 6a50297 commit c7556fc

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

packages/uui-button/lib/uui-button.element.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,15 @@ export class UUIButtonElement extends UUIFormControlMixin(
137137
@property({ type: String })
138138
public rel?: string;
139139

140+
/**
141+
* Sets the title attribute, which provides a tooltip for both button and anchor elements.
142+
* @type {string}
143+
* @attr
144+
* @default ''
145+
*/
146+
@property({ type: String })
147+
public title: string = '';
148+
140149
@query('#button')
141150
protected _button!: HTMLInputElement;
142151

@@ -237,6 +246,7 @@ export class UUIButtonElement extends UUIFormControlMixin(
237246
<a
238247
id="button"
239248
aria-label=${ifDefined(this.label)}
249+
title=${ifDefined(this.title === '' ? undefined : this.title)}
240250
href=${ifDefined(!this.disabled ? this.href : undefined)}
241251
target=${ifDefined(this.target || undefined)}
242252
rel=${ifDefined(
@@ -254,7 +264,8 @@ export class UUIButtonElement extends UUIFormControlMixin(
254264
id="button"
255265
type=${this.type}
256266
?disabled=${this.disabled}
257-
aria-label=${ifDefined(this.label)}>
267+
aria-label=${ifDefined(this.label)}
268+
title=${ifDefined(this.title === '' ? undefined : this.title)}>
258269
${this.renderState()} ${this.renderLabel()}
259270
<slot name="extra"></slot>
260271
</button>

0 commit comments

Comments
 (0)