@@ -29,6 +29,7 @@ const CSSGrid = React.forwardRef<
2929 condensed = false ,
3030 fullWidth = false ,
3131 narrow = false ,
32+ withRowGap,
3233 ...rest
3334 } ,
3435 ref ?
@@ -50,6 +51,7 @@ const CSSGrid = React.forwardRef<
5051 as = { as }
5152 className = { customClassName }
5253 mode = { mode }
54+ withRowGap = { withRowGap }
5355 { ...rest } >
5456 { children }
5557 </ Subgrid >
@@ -64,6 +66,7 @@ const CSSGrid = React.forwardRef<
6466 [ `${ prefix } --css-grid--full-width` ] : fullWidth ,
6567 [ `${ prefix } --css-grid--start` ] : align === 'start' ,
6668 [ `${ prefix } --css-grid--end` ] : align === 'end' ,
69+ [ `${ prefix } --css-grid--with-row-gap` ] : withRowGap ,
6770 } ) ;
6871
6972 // cast as any to let TypeScript allow passing in attributes to base component
@@ -115,6 +118,12 @@ CSSGrid.propTypes = {
115118 * typographic alignment with and without containers.
116119 */
117120 narrow : PropTypes . bool ,
121+
122+ /**
123+ * Add a row gap to the grid that matches the current gutter size.
124+ * This is useful when you want consistent vertical spacing between rows.
125+ */
126+ withRowGap : PropTypes . bool ,
118127} ;
119128
120129type SubgridMode = 'wide' | 'narrow' | 'condensed' ;
@@ -134,6 +143,12 @@ interface SubgridBaseProps {
134143 * Specify the gutter mode for the subgrid
135144 */
136145 mode ?: SubgridMode ;
146+
147+ /**
148+ * Add a row gap to the subgrid that matches the current gutter size.
149+ * This is useful when you want consistent vertical spacing between rows.
150+ */
151+ withRowGap ?: boolean ;
137152}
138153
139154// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20452
@@ -143,21 +158,27 @@ const Subgrid = React.forwardRef<
143158 SubgridBaseProps & {
144159 as ?: React . ElementType ;
145160 } & React . HTMLAttributes < HTMLDivElement >
146- > ( ( { as, className : customClassName , children, mode, ...rest } , ref ) => {
147- const prefix = usePrefix ( ) ;
148- const className = cx ( customClassName , {
149- [ `${ prefix } --subgrid` ] : true ,
150- [ `${ prefix } --subgrid--condensed` ] : mode === 'condensed' ,
151- [ `${ prefix } --subgrid--narrow` ] : mode === 'narrow' ,
152- [ `${ prefix } --subgrid--wide` ] : mode === 'wide' ,
153- } ) ;
154- const BaseComponent = as || 'div' ;
155- return (
156- < BaseComponent { ...rest } ref = { ref } className = { className } >
157- { children }
158- </ BaseComponent >
159- ) ;
160- } ) ;
161+ > (
162+ (
163+ { as, className : customClassName , children, mode, withRowGap, ...rest } ,
164+ ref
165+ ) => {
166+ const prefix = usePrefix ( ) ;
167+ const className = cx ( customClassName , {
168+ [ `${ prefix } --subgrid` ] : true ,
169+ [ `${ prefix } --subgrid--condensed` ] : mode === 'condensed' ,
170+ [ `${ prefix } --subgrid--narrow` ] : mode === 'narrow' ,
171+ [ `${ prefix } --subgrid--wide` ] : mode === 'wide' ,
172+ [ `${ prefix } --subgrid--with-row-gap` ] : withRowGap ,
173+ } ) ;
174+ const BaseComponent = as || 'div' ;
175+ return (
176+ < BaseComponent { ...rest } ref = { ref } className = { className } >
177+ { children }
178+ </ BaseComponent >
179+ ) ;
180+ }
181+ ) ;
161182
162183Subgrid . propTypes = {
163184 /**
@@ -179,6 +200,12 @@ Subgrid.propTypes = {
179200 * Specify the gutter mode for the subgrid
180201 */
181202 mode : PropTypes . oneOf ( [ 'wide' , 'narrow' , 'condensed' ] as SubgridMode [ ] ) ,
203+
204+ /**
205+ * Add a row gap to the grid that matches the current gutter size.
206+ * This is useful when you want consistent vertical spacing between rows.
207+ */
208+ withRowGap : PropTypes . bool ,
182209} ;
183210
184211const CSSGridComponent : GridComponent = CSSGrid ;
0 commit comments