@@ -10,6 +10,8 @@ import styles from './Box.scss';
1010
1111type Element = 'div' | 'span' ;
1212
13+ type Overflow = 'hidden' | 'scroll' ;
14+
1315export type BackgroundColorTokenScale =
1416 | 'action-critical'
1517 | 'action-critical-depressed'
@@ -164,8 +166,12 @@ export interface BoxProps {
164166 color ?: ColorTokenScale ;
165167 /** HTML id attribute */
166168 id ?: string ;
167- /** Spacing outside of container */
169+ /** Set maximum width of container */
168170 maxWidth ?: string ;
171+ /** Clip horizontal content of children */
172+ overflowX ?: Overflow ;
173+ /** Clip vertical content of children */
174+ overflowY ?: Overflow ;
169175 /** Spacing around children */
170176 padding ?: SpacingSpaceScale ;
171177 /** Bottom spacing around children */
@@ -178,6 +184,8 @@ export interface BoxProps {
178184 paddingTop ?: SpacingSpaceScale ;
179185 /** Shadow */
180186 shadow ?: DepthShadowAlias ;
187+ /** Set width of container */
188+ width ?: string ;
181189}
182190
183191export const Box = forwardRef < HTMLElement , BoxProps > (
@@ -199,12 +207,15 @@ export const Box = forwardRef<HTMLElement, BoxProps>(
199207 color,
200208 id,
201209 maxWidth,
210+ overflowX,
211+ overflowY,
202212 padding,
203213 paddingBottom,
204214 paddingLeft,
205215 paddingRight,
206216 paddingTop,
207217 shadow,
218+ width,
208219 } ,
209220 ref ,
210221 ) => {
@@ -270,7 +281,9 @@ export const Box = forwardRef<HTMLElement, BoxProps>(
270281 }
271282 : undefined ) ,
272283 ...( color ? { '--pc-box-color' : `var(--p-${ color } )` } : undefined ) ,
273- ...( maxWidth ? { '--pc-box-max-width' : `${ maxWidth } px` } : undefined ) ,
284+ ...( maxWidth ? { '--pc-box-max-width' : `${ maxWidth } ` } : undefined ) ,
285+ ...( overflowX ? { '--pc-box-overflow-x' : `${ overflowX } ` } : undefined ) ,
286+ ...( overflowY ? { '--pc-box-overflow-y' : `${ overflowY } ` } : undefined ) ,
274287 ...( paddings . bottom
275288 ? { '--pc-box-padding-bottom' : `var(--p-space-${ paddings . bottom } )` }
276289 : undefined ) ,
@@ -286,6 +299,7 @@ export const Box = forwardRef<HTMLElement, BoxProps>(
286299 ...( shadow
287300 ? { '--pc-box-shadow' : `var(--p-shadow-${ shadow } )` }
288301 : undefined ) ,
302+ ...( width ? { '--pc-box-max-width' : `${ width } ` } : undefined ) ,
289303 } as React . CSSProperties ;
290304
291305 const className = classNames ( styles . Box ) ;
0 commit comments