@@ -15,13 +15,24 @@ import {
1515} from "react-aria-components" ;
1616
1717interface TabsItem {
18+ /** Unique id for each tab panel */
1819 id : Key ;
1920 text : string ;
21+ /** Value associated with each tab. Passed as an arg to callback function. */
2022 value : any ;
2123 Icon ?: React . FC < React . SVGAttributes < SVGElement > > ;
2224 icon ?: React . ReactNode ;
2325 disabled ?: boolean ;
26+ /** Content to display when this tab is selected. */
2427 content : ReactNode ;
28+ /** Props for Tab
29+ * {@link https://react-spectrum.adobe.com/react-aria/Tabs.html#tab | TabProps}
30+ */
31+ tabProps ?: TabProps ;
32+ /**
33+ * Can be used to provide separate styling for a TabPanel, apart from one passed in panelClassName parent props.
34+ * {@link https://react-spectrum.adobe.com/react-aria/Tabs.html#tabpanel | TabListProps}
35+ */
2536 tabPanelProps ?: TabPanelProps ;
2637}
2738
@@ -30,19 +41,24 @@ interface TabsProps extends Omit<AriaTabsProps, "orientation"> {
3041 // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
3142 callback ?: Function ;
3243 className ?: string ;
44+ /** ClassName to provide a common style for all TabPanels */
3345 panelClassName ?: string ;
46+ /**
47+ * Can be used to override default style.
48+ * {@link https://react-spectrum.adobe.com/react-aria/Tabs.html#tablist | TabListProps}
49+ */
3450 tabListProps ?: TabListProps < TabProps > ;
3551}
3652
37- const Tabs : React . FC < TabsProps > = ( {
53+ function Tabs ( {
3854 items,
3955 className,
4056 tabListProps,
4157 panelClassName,
4258 callback,
4359 defaultSelectedKey,
4460 ...props
45- } ) => {
61+ } : Readonly < TabsProps > ) {
4662 const [ selectedKey , setSelectedKey ] = useState < Key | undefined > (
4763 defaultSelectedKey ,
4864 ) ;
@@ -114,7 +130,7 @@ const Tabs: React.FC<TabsProps> = ({
114130 className = { cn (
115131 "box-border h-fit w-full" ,
116132 panelClassName ,
117- // custom style for a panel should override global style provided with panelClassName
133+ // custom style for a panel should override parent style provided with panelClassName
118134 item ?. tabPanelProps ?. className ,
119135 ) }
120136 { ...item . tabPanelProps }
@@ -125,6 +141,6 @@ const Tabs: React.FC<TabsProps> = ({
125141 </ Collection >
126142 </ AriaTabs >
127143 ) ;
128- } ;
144+ }
129145
130146export default Tabs ;
0 commit comments