Back to PrimitivesView on GitHubMain content Sidebar
GridItem
1:1LayoutGrid child element.
Example
Usage
import { Grid, GridItem, Box } from '@/components/polaris';
function Example() {
return (
<Grid gridTemplateColumns="2fr 1fr" gap="base">
<GridItem>
<Box padding="base" background="subdued">Main content</Box>
</GridItem>
<GridItem>
<Box padding="base" background="subdued">Sidebar</Box>
</GridItem>
</Grid>
);
}Component Source
import { forwardRef, createElement } from 'react';
type Props = JSX.IntrinsicElements['s-grid-item'];
/**
* GridItem component - child element within a Grid.
*
* @example
* <Grid gridTemplateColumns="1fr 1fr">
* <GridItem>Column 1</GridItem>
* <GridItem>Column 2</GridItem>
* </Grid>
*/
export const GridItem = forwardRef<HTMLElement, Props>((props, ref) => createElement('s-grid-item', { ref, ...props }));
GridItem.displayName = 'GridItem';