Skip to content

Commit 18b3d24

Browse files
authored
fix(button): add support for external links (#284)
1 parent 58b2f8b commit 18b3d24

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/components/button/index.tsx

+17
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface QuartzButtonProps extends Omit<ButtonProps, 'css'> {
1616
intent?: Intent;
1717
icon?: IconName;
1818
href?: string;
19+
external?: boolean;
1920
isLoading?: boolean;
2021
loadingOnly?: boolean;
2122
}
@@ -29,6 +30,7 @@ const Button: FC<QuartzButtonProps> = ({
2930
isLoading,
3031
loadingOnly,
3132
target,
33+
external,
3234
...props
3335
}: QuartzButtonProps) => {
3436
const test = { ...props };
@@ -50,6 +52,21 @@ const Button: FC<QuartzButtonProps> = ({
5052
);
5153

5254
if (href) {
55+
if (external) {
56+
return (
57+
<a
58+
style={{
59+
textDecoration: 'none',
60+
}}
61+
href={href}
62+
target={target}
63+
{...(target === '_blank' ? { rel: 'noopener noreferrer' } : {})}
64+
>
65+
{component}
66+
</a>
67+
);
68+
}
69+
5370
return (
5471
<Link
5572
style={{

0 commit comments

Comments
 (0)