2026-02-06 09:12:33 +00:00
|
|
|
import * as React from 'react';
|
|
|
|
|
import { cn } from '@/lib/utils';
|
|
|
|
|
import type { TabsContentProps } from './types';
|
|
|
|
|
|
|
|
|
|
export const TabsContent = React.forwardRef<HTMLDivElement, TabsContentProps>(
|
|
|
|
|
(
|
2026-02-09 22:04:35 +00:00
|
|
|
{ className, value: contentValue, activeValue, tabsId, children, ...props },
|
2026-02-06 09:12:33 +00:00
|
|
|
ref,
|
|
|
|
|
) => {
|
|
|
|
|
if (activeValue !== contentValue) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-09 22:04:35 +00:00
|
|
|
const panelId = tabsId ? `${tabsId}-panel-${contentValue}` : undefined;
|
|
|
|
|
const tabId = tabsId ? `${tabsId}-tab-${contentValue}` : undefined;
|
|
|
|
|
|
2026-02-06 09:12:33 +00:00
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
ref={ref}
|
2026-02-09 22:04:35 +00:00
|
|
|
id={panelId}
|
|
|
|
|
role="tabpanel"
|
|
|
|
|
aria-labelledby={tabId}
|
|
|
|
|
tabIndex={0}
|
2026-02-06 09:12:33 +00:00
|
|
|
className={cn(
|
2026-02-07 13:17:49 +00:00
|
|
|
'mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
|
2026-02-06 09:12:33 +00:00
|
|
|
className,
|
|
|
|
|
)}
|
|
|
|
|
{...props}
|
|
|
|
|
>
|
|
|
|
|
{children}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
TabsContent.displayName = 'TabsContent';
|