@@ -5,7 +5,6 @@ import {getResponsiveAttributes} from '../internal/utils/getResponsiveAttributes
55import classes from './Stack.module.css'
66import { clsx } from 'clsx'
77import type { ForwardRefComponent as PolymorphicForwardRefComponent } from '../utils/polymorphic'
8- import { BoxWithFallback } from '../internal/components/BoxWithFallback'
98
109type GapScale = 'none' | 'condensed' | 'normal' | 'spacious'
1110type Gap = GapScale | ResponsiveValue < GapScale >
@@ -71,7 +70,7 @@ type StackProps<As> = React.PropsWithChildren<{
7170const Stack = forwardRef (
7271 (
7372 {
74- as,
73+ as : Component = 'div' ,
7574 children,
7675 align = 'stretch' ,
7776 direction = 'vertical' ,
@@ -85,8 +84,7 @@ const Stack = forwardRef(
8584 forwardedRef ,
8685 ) => {
8786 return (
88- < BoxWithFallback
89- as = { as }
87+ < Component
9088 ref = { forwardedRef }
9189 { ...rest }
9290 className = { clsx ( className , classes . Stack ) }
@@ -98,7 +96,7 @@ const Stack = forwardRef(
9896 { ...getResponsiveAttributes ( 'padding' , padding ) }
9997 >
10098 { children }
101- </ BoxWithFallback >
99+ </ Component >
102100 )
103101 } ,
104102) as PolymorphicForwardRefComponent < ElementType , StackProps < ElementType > >
@@ -124,18 +122,17 @@ type StackItemProps<As> = React.PropsWithChildren<{
124122 className ?: string
125123} >
126124
127- const StackItem = forwardRef ( ( { as, children, grow, shrink, className, ...rest } , forwardedRef ) => {
125+ const StackItem = forwardRef ( ( { as : Component = 'div' , children, grow, shrink, className, ...rest } , forwardedRef ) => {
128126 return (
129- < BoxWithFallback
130- as = { as }
127+ < Component
131128 ref = { forwardedRef }
132129 { ...rest }
133130 className = { clsx ( className , classes . StackItem ) }
134131 { ...getResponsiveAttributes ( 'grow' , grow ) }
135132 { ...getResponsiveAttributes ( 'shrink' , shrink ) }
136133 >
137134 { children }
138- </ BoxWithFallback >
135+ </ Component >
139136 )
140137} ) as PolymorphicForwardRefComponent < ElementType , StackProps < ElementType > >
141138
0 commit comments