-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add download attribute to Button and UnstyledLink #1027
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
Conversation
0e2d2e5
to
719a80f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth adding an example of each to the style guide.
Otherwise, looks good to me!
719a80f
to
10762f5
Compare
10762f5
to
d039289
Compare
Comments addressed! I don't think it is worth adding an example - there's no visual change and finding a non-contrived example might be tricky as |
This allows you to download the url instead of opening it. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-download
d039289
to
a378e60
Compare
WHY are these changes introduced?
I've got a use case where I want a Button that triggers the download of a file instead of opening it.
The web provides support for this using the download attribute (see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-download) but there's no way to expose that currently
WHAT is this pull request doing?
Adds a
download
prop to the Button and UnstyledLink components. It may either betrue
to render<a href="foo" download>
or a string to render<a href="foo" download="downloadPropValue">
which acts as a hint for the filename to use when saving the file.This only has an effect when you pass a
url
to a button but I think that's ok, asexternal
acts in a similar way.How to 🎩
On the playground click the various buttons and see the behaviour.
Copy-paste this code in
playground/Playground.tsx
:🎩 checklist