Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(docsite): make 'Open in Playground' a real link (#3191)

Durvesh Pilankar17acc48772c0
diff --git a/apps/docsite/src/components/PlaygroundButton.tsx b/apps/docsite/src/components/PlaygroundButton.tsx
index d9f0ae5934..f8c7b413ed 100644
--- a/apps/docsite/src/components/PlaygroundButton.tsx
+++ b/apps/docsite/src/components/PlaygroundButton.tsx
@@ -16,14 +16,8 @@ export function PlaygroundButton({
}: PlaygroundButtonProps) {
const href = buildPlaygroundHref(source);
- return (
- <Button
- label={label}
- variant="secondary"
- size="sm"
- onClick={() => {
- window.location.href = href;
- }}
- />
- );
+ // Render a real anchor (Button renders as <a> when given href) so
+ // right-click / Cmd-click / middle-click "open in new tab" work, instead
+ // of an onClick that hard-navigates the current tab.
+ return <Button label={label} variant="secondary" size="sm" href={href} />;
}
diff --git a/apps/docsite/src/components/component-detail/ExampleBlock.tsx b/apps/docsite/src/components/component-detail/ExampleBlock.tsx
index 7c1f4503c5..5955ce059f 100644
--- a/apps/docsite/src/components/component-detail/ExampleBlock.tsx
+++ b/apps/docsite/src/components/component-detail/ExampleBlock.tsx
@@ -107,9 +107,12 @@ export function ExampleBlock({entry, componentName}: ExampleBlockProps) {
label="Open in Playground"
variant="ghost"
size="sm"
+ // Real anchor (Button renders <a> with href) so right-click /
+ // Cmd-click / middle-click "open in new tab" work. onClick stays
+ // for analytics; the href handles navigation natively.
+ href={buildPlaygroundHref(entry.source)}
onClick={() => {
trackOpenPlayground({page: 'components', item: entry.name});
- window.location.href = buildPlaygroundHref(entry.source);
}}
/>
)}