) {
- return (
+ const ctx = use(TabsContext);
+ const hasVariants = (ctx?.variants?.length ?? 0) > 0;
+
+ const tabsList = (
) {
props.className,
)}
>
- {props.children}
+ {/* Tab pills — left side */}
+ {props.children}
);
+
+ if (!hasVariants || !ctx) {
+ return tabsList;
+ }
+
+ return (
+
+ {tabsList}
+ {/* Variant dropdown — right side, sibling of TabsList */}
+
+
+ );
}
+// ---------------------------------------------------------------------------
+// CodeBlockTabsTrigger
+// ---------------------------------------------------------------------------
+
export function CodeBlockTabsTrigger({
children,
...props
}: ComponentProps) {
+ const ctx = use(TabsContext);
+
+ // Check if this tab has content for the currently selected variant
+ const hasVariants = (ctx?.variants?.length ?? 0) > 0;
+ const isAvailable =
+ !hasVariants ||
+ !ctx?.availableTabs ||
+ ctx.availableTabs.has(props.value as string);
+
return (
@@ -268,6 +443,34 @@ export function CodeBlockTabsTrigger({
);
}
-export function CodeBlockTab(props: ComponentProps) {
- return ;
+// ---------------------------------------------------------------------------
+// CodeBlockTab
+// ---------------------------------------------------------------------------
+
+export interface CodeBlockTabProps extends ComponentProps {
+ /**
+ * When inside a multi-axis CodeBlockTabs, declare which variant this
+ * content belongs to. Content is only rendered when both the parent tab
+ * is active AND this variant matches the dropdown selection.
+ */
+ variant?: string;
+}
+
+export function CodeBlockTab({
+ variant,
+ children,
+ ...props
+}: CodeBlockTabProps) {
+ const ctx = use(TabsContext);
+
+ // If this tab has a variant declared, only render its children when the
+ // active variant matches. The TabsContent visibility is still controlled
+ // by Radix (active tab), so we only gate the inner content.
+ const hasVariants = (ctx?.variants?.length ?? 0) > 0;
+ const variantMatch =
+ !variant || !hasVariants || ctx?.activeVariant === variant;
+
+ if (!variantMatch) return null;
+
+ return {children};
}