carbon-components-svelte icon indicating copy to clipboard operation
carbon-components-svelte copied to clipboard

Vertical & horizontal centering options in grid?

Open hjhjdev opened this issue 3 years ago • 1 comments

Hello, I was playing with carbon components, found there's no centering options in this package. Like creating login page, there's a need for centering options in grid. From carbon design guidelines, we can see some images like below:

Are there ways to achieve this? Simply adding parent div and adding flexbox doesn't work at all.

hjhjdev avatar Oct 23 '21 20:10 hjhjdev

Generally, I would recommend writing custom CSS for vertical/horizontal centering.

However, if you're using the Grid from Carbon, you can use the offset prop to "center" a column.

Carbon Components Svelte forces a 16 column grid. In the example below, we have a column that spans 4 columns and has a left offset of 6 columns.

6 + 4 + 6 = 16

<Grid>
  <Row>
    <Column xlg={{ span: 4, offset: 6 }}>Column</Column>
  </Row>
</Grid>

metonym avatar Nov 17 '21 21:11 metonym