@navikt/ds-react
Version:
React components from the Norwegian Labour and Welfare Administration.
19 lines (15 loc) • 435 B
text/typescript
import { useTabsContext } from "../../Tabs.context";
type TabPanelProps = {
value: string;
};
/**
* Tabs hook for managing the visible/hidden state of Tabs.Panel
*/
export function useTabPanel({ value }: TabPanelProps) {
const { id, selectedValue, makeTabId, makeTabPanelId } = useTabsContext();
return {
labelledbyId: makeTabId(id, value),
hidden: selectedValue !== value,
id: makeTabPanelId(id, value),
};
}