I’m working on a React component using @forge/react and facing an issue where a <Stack> element does not fill the full height of its parent <Box>.
The parent <Box> has a fixed height of 185px, and I need the <Stack> inside it to stretch and utilize 100% of this height. I’ve set spread="space-between" and grow="fill" on the <Stack> to try and make it fill the available space, but it doesn’t seem to work as expected.
Dependencies:
react: ^18.2.0@forge/react: 10.7.0
Here’s the relevant code snippet:
import { Box, Heading, Icon, Inline, Stack, Text } from '@forge/react';
export const InfoBlock = ({
title, thresholdValue, criticalCount, warningCount
}: {
title: string,
thresholdValue: number,
criticalCount: number,
warningCount: number,
}) => {
return (
<Box
xcss={{
borderRadius: 'border.radius',
borderStyle: 'solid',
borderWidth: 'border.width',
borderColor: 'color.border.accent.gray',
padding: 'space.150',
width: '100%',
height: '185px',
}}
>
// I NEED THE STACK ELEMENT BELOW 100% height
<Stack spread={'space-between'}
alignBlock="stretch"
grow={'fill'}
space="space.400">
{/* Title and threshold */}
<Stack grow={'hug'} alignBlock={'stretch'}>
<Inline alignInline={'center'}>
{/* Placeholder for multiline header */}
<Box xcss={{ height: '70px' }}></Box>
<Heading as="h2">{title}</Heading>
</Inline>
<Inline alignInline={'center'}>
<Heading as="h3">
<Box xcss={{ color: 'color.text.accent.blue' }}>
Threshold: {thresholdValue}
</Box>
</Heading>
</Inline>
</Stack>
{/* Status data */}
<Stack space="space.100" alignInline="stretch" alignBlock="end" grow={'fill'}>
<Inline space="space.050">
<Box xcss={{ width: '25%' }}>
{(() => {
if (criticalCount === 0 && warningCount === 0) {
return (
<Icon
label="Success"
primaryColor="color.icon.success"
size="large"
glyph="editor-success"
/>
);
} else if (criticalCount === 0 && warningCount > 0) {
return (
<Icon
label="Warning"
primaryColor="color.icon.accent.yellow"
size="medium"
glyph="info"
/>
);
} else if (criticalCount > 0) {
return (
<Icon
label="Critical"
primaryColor="color.icon.danger"
size="medium"
glyph="cross-circle"
/>
);
} else {
return null; // Default case if none of the conditions match
}
})()}
</Box>
<Box xcss={{ width: '75%' }}>
{criticalCount != null && (
<Inline alignBlock={'center'}>
<Heading as='h5'>
<Text>
Critical: {criticalCount}
</Text>
</Heading>
</Inline>
)}
{warningCount != null && (
<Inline alignBlock={'center'}>
<Heading as='h5'>
<Text>
Warning: {warningCount}
</Text>
</Heading>
</Inline>
)}
</Box>
</Inline>
</Stack>
</Stack>
</Box>
)
}
What I need:
The <Stack> element should consistently span the full height of the parent <Box> (185px), allowing proper alignment and spacing for its child elements.
flex: 1 not working inside box (display: block), would be awesome just set height:100% to Stack element.
Does anyone know how to fix this?

