Skip to content

FlexItem

Demo

Contents
Code Editor
<Layout.FlexItem>Contents</Layout.FlexItem>

Advanced size

FlexItem
FlexItem
FlexItem
FlexItem
Code Editor
const breakpoints = {
  ...defaultBreakpoints,
  xsmall: '30em',
}
const queries = {
  ...defaultQueries,
  xsmall: {
    min: 0,
    max: 'xsmall',
  },
  small: {
    min: 'xsmall',
    max: 'small',
  },
}
const CustomMediaQuery = styled.div`
  .dnb-layout__flex-container[data-media-key='xsmall']
    .dnb-layout__flex-item--responsive {
    --size: var(--xsmall);
  }
`
render(
  <CustomMediaQuery>
    <Layout.FlexContainer
      direction="horizontal"
      wrap
      columns={4}
      breakpoints={breakpoints}
      queries={queries}
    >
      <Layout.FlexItem
        size={{
          small: 2,
          medium: 3,
          large: 1,
        }}
      >
        <TestElement style={colors[0]}>FlexItem</TestElement>
      </Layout.FlexItem>
      <Layout.FlexItem
        size={{
          small: 2,
          medium: 1,
          large: 2,
        }}
      >
        <TestElement style={colors[1]}>FlexItem</TestElement>
      </Layout.FlexItem>
      <Layout.FlexItem
        size={{
          xsmall: 4,
          small: 2,
          medium: 1,
          large: 1,
        }}
      >
        <TestElement style={colors[2]}>FlexItem</TestElement>
      </Layout.FlexItem>
      <Layout.FlexItem
        size={{
          xsmall: 4,
          small: 2,
          medium: 3,
          large: 4,
        }}
      >
        <TestElement style={colors[3]}>FlexItem</TestElement>
      </Layout.FlexItem>
    </Layout.FlexContainer>
  </CustomMediaQuery>,
)