Skip to content

A games launcher for GOG, Amazon and Epic Games for Linux, Windows and macOS.

946 B
Raw Blame
import React, { HTMLProps } from 'react'

type TabPanelProps = HTMLProps<HTMLDivElement> & {
  children?: React.ReactNode
  index: string
  value: string
  // Must match the idPrefix passed to the Tabs that controls this panel.
  idPrefix?: string
  // Keep the children mounted while the panel is hidden, for panels whose
  // children initialize state needed by the dialog.
  keepMounted?: boolean
}

function TabPanel(props: Readonly<TabPanelProps>) {
  const {
    children,
    value,
    index,
    idPrefix = 'tab',
    keepMounted = false,
    ...other
  } = props

  return (
    <div
      role="tabpanel"
      id={`${idPrefix}panel-${index}`}
      aria-labelledby={`${idPrefix}-${index}`}
      hidden={value !== index}
      {...other}
    >
      {keepMounted ? (
        <div hidden={value !== index}>{children}</div>
      ) : (
        value === index && <div>{children}</div>
      )}
    </div>
  )
}

export default TabPanel