Skip to content

Commit 919fe12

Browse files
Merge pull request #5769 from TonySpegel:feat/button-download-filename
PiperOrigin-RevId: 723241863
2 parents 29d6763 + 9e84130 commit 919fe12

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

Diff for: button/internal/button.ts

+8
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ export abstract class Button extends buttonBaseClass implements FormSubmitter {
6767
*/
6868
@property() href = '';
6969

70+
/**
71+
* The filename to use when downloading the linked resource.
72+
* If not specified, the browser will determine a filename.
73+
* This is only applicable when the button is used as a link (`href` is set).
74+
*/
75+
@property() download = '';
76+
7077
/**
7178
* Where to display the linked `href` URL for a link button. Common options
7279
* include `_blank` to open in a new tab.
@@ -184,6 +191,7 @@ export abstract class Button extends buttonBaseClass implements FormSubmitter {
184191
aria-haspopup="${ariaHasPopup || nothing}"
185192
aria-expanded="${ariaExpanded || nothing}"
186193
href=${this.href}
194+
download=${this.download || nothing}
187195
target=${this.target || nothing}
188196
>${this.renderContent()}
189197
</a>`;

Diff for: chips/internal/assist-chip.ts

+7
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ import {Chip} from './chip.js';
1919
export class AssistChip extends Chip {
2020
@property({type: Boolean}) elevated = false;
2121
@property() href = '';
22+
/**
23+
* The filename to use when downloading the linked resource.
24+
* If not specified, the browser will determine a filename.
25+
* This is only applicable when the chip is used as a link (`href` is set).
26+
*/
27+
@property() download = '';
2228
@property() target: '_blank' | '_parent' | '_self' | '_top' | '' = '';
2329

2430
protected get primaryId() {
@@ -49,6 +55,7 @@ export class AssistChip extends Chip {
4955
id="link"
5056
aria-label=${ariaLabel || nothing}
5157
href=${this.href}
58+
download=${this.download || nothing}
5259
target=${this.target || nothing}
5360
>${content}</a
5461
>

Diff for: iconbutton/internal/icon-button.ts

+8
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ export class IconButton extends iconButtonBaseClass implements FormSubmitter {
7979
*/
8080
@property() href = '';
8181

82+
/**
83+
* The filename to use when downloading the linked resource.
84+
* If not specified, the browser will determine a filename.
85+
* This is only applicable when the icon button is used as a link (`href` is set).
86+
*/
87+
@property() download = '';
88+
8289
/**
8390
* Sets the underlying `HTMLAnchorElement`'s `target` attribute.
8491
*/
@@ -191,6 +198,7 @@ export class IconButton extends iconButtonBaseClass implements FormSubmitter {
191198
class="link"
192199
id="link"
193200
href="${this.href}"
201+
download="${this.download || nothing}"
194202
target="${this.target || nothing}"
195203
aria-label="${ariaLabel || nothing}">
196204
${this.renderTouchTarget()}

0 commit comments

Comments
 (0)