Skip to content

Commit 055d3f7

Browse files
committed
refactor: narrow props for List, Tab, and Panel sub-components
Apply Pick<> type narrowing to List, Tab, and Panel sub-components, matching the same pattern already used by Root. This prevents Base UI internal props from leaking into AppShell's public API surface.
1 parent 7c2e5ff commit 055d3f7

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

packages/core/src/components/tabs.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Tabs as BaseTabs } from "@base-ui/react/tabs";
33

44
import { cn } from "@/lib/utils";
55

6-
// Only the props relevant to the Tabs abstraction are picked from BaseTabs.Root.
6+
// Only the props relevant to the Tabs abstraction are picked from Base UI.
77
// Base UI-internal props are intentionally excluded so that upstream changes
88
// don't leak as breaking changes to consumers.
99
type RootProps = Pick<
@@ -40,8 +40,10 @@ function Root({ className, children, ...props }: RootProps) {
4040
}
4141
Root.displayName = "Tabs.Root";
4242

43+
type ListProps = Pick<React.ComponentProps<typeof BaseTabs.List>, "children" | "className">;
44+
4345
/** Groups the individual tab buttons. */
44-
function List({ className, children, ...props }: React.ComponentProps<typeof BaseTabs.List>) {
46+
function List({ className, children, ...props }: ListProps) {
4547
return (
4648
<BaseTabs.List
4749
data-slot="tabs-list"
@@ -57,8 +59,13 @@ function List({ className, children, ...props }: React.ComponentProps<typeof Bas
5759
}
5860
List.displayName = "Tabs.List";
5961

62+
type TabProps = Pick<
63+
React.ComponentProps<typeof BaseTabs.Tab>,
64+
"value" | "disabled" | "children" | "className"
65+
>;
66+
6067
/** An individual interactive tab button that toggles the corresponding panel. */
61-
function Tab({ className, children, ...props }: React.ComponentProps<typeof BaseTabs.Tab>) {
68+
function Tab({ className, children, ...props }: TabProps) {
6269
return (
6370
<BaseTabs.Tab
6471
data-slot="tabs-tab"
@@ -78,8 +85,13 @@ function Tab({ className, children, ...props }: React.ComponentProps<typeof Base
7885
}
7986
Tab.displayName = "Tabs.Tab";
8087

88+
type PanelProps = Pick<
89+
React.ComponentProps<typeof BaseTabs.Panel>,
90+
"value" | "keepMounted" | "children" | "className"
91+
>;
92+
8193
/** A panel displayed when the corresponding tab is active. */
82-
function Panel({ className, children, ...props }: React.ComponentProps<typeof BaseTabs.Panel>) {
94+
function Panel({ className, children, ...props }: PanelProps) {
8395
return (
8496
<BaseTabs.Panel
8597
data-slot="tabs-panel"

0 commit comments

Comments
 (0)