-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stack component #48
Stack component #48
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<template> | ||
<CStack :spacing="5"> | ||
<CBox :p="5" shadow="md" border-width="1px"> | ||
<CHeading>See the Vue</CHeading> | ||
<CText :mt="4">Vue makes front-end development a breeze.</CText> | ||
</CBox> | ||
<CBox :p="5" shadow="md" border-width="1px"> | ||
<CHeading>Go Nuxt!</CHeading> | ||
<CText :mt="4">Nuxt makes writing Vue even easier.</CText> | ||
</CBox> | ||
</CStack> | ||
</template> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<template> | ||
<CStack :spacing="5" is-inline> | ||
<CBox :p="5" shadow="md" border-width="1px"> | ||
<CHeading>See the Vue</CHeading> | ||
<CText :mt="4">Vue makes front-end development a breeze.</CText> | ||
</CBox> | ||
<CBox :p="5" shadow="md" border-width="1px"> | ||
<CHeading>Go Nuxt!</CHeading> | ||
<CText :mt="4">Nuxt makes writing Vue even easier.</CText> | ||
</CBox> | ||
</CStack> | ||
</template> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<template> | ||
<CHStack :spacing="5"> | ||
<CBox :p="5" shadow="md" border-width="1px"> | ||
<CHeading>See the Vue</CHeading> | ||
<CText :mt="4">Vue makes front-end development a breeze.</CText> | ||
</CBox> | ||
<CBox :p="5" shadow="md" border-width="1px"> | ||
<CHeading>Go Nuxt!</CHeading> | ||
<CText :mt="4">Nuxt makes writing Vue even easier.</CText> | ||
</CBox> | ||
</CHStack> | ||
</template> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<template> | ||
<CStack :spacing="4"> | ||
<CText>Chakra component 1</CText> | ||
<p>HTML paragraph element</p> | ||
<h3>HTML heading element</h3> | ||
<CText>Chakra component 2</CText> | ||
</CStack> | ||
</template> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<template> | ||
<CStack :spacing="5" direction="column-reverse"> | ||
<CBox :p="5" shadow="md" border-width="1px"> | ||
<CHeading>See the Vue</CHeading> | ||
<CText :mt="4">Vue makes front-end development a breeze.</CText> | ||
</CBox> | ||
<CBox :p="5" shadow="md" border-width="1px"> | ||
<CHeading>Go Nuxt!</CHeading> | ||
<CText :mt="4">Nuxt makes writing Vue even easier.</CText> | ||
</CBox> | ||
</CStack> | ||
</template> |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,141 @@ | ||||||
--- | ||||||
title: Stack | ||||||
description: Stack Component | ||||||
version: 2.0+ | ||||||
--- | ||||||
|
||||||
# Stack | ||||||
|
||||||
Stack is a layout utility component that makes it easy to stack elements together and apply a space between them. It composes the `Flex` component. | ||||||
|
||||||
## Import | ||||||
|
||||||
By default, each item is stacked vertically. `CStack` clones its children and passes the spacing to them using `margin-bottom` or `margin-right`. | ||||||
|
||||||
```js | ||||||
import { CStack } from '@chakra-ui/vue-next'; | ||||||
``` | ||||||
|
||||||
In addition, Chakra-UI Vue exports two additional `CStack` components | ||||||
- `CVStack`: used to stack elements in the vertical direction | ||||||
- `CHStack`: used to stack elements in the horizontal direction | ||||||
|
||||||
```js | ||||||
import { CStack, CHStack, CVStack } from '@chakra-ui/vue-next'; | ||||||
``` | ||||||
|
||||||
## Usage | ||||||
|
||||||
::showcase | ||||||
::basic-stack | ||||||
:: | ||||||
:: | ||||||
|
||||||
```html | ||||||
<CStack :spacing="5"> | ||||||
<CBox :p="5" shadow="md" border-width="1px"> | ||||||
<CHeading>See the Vue</c-heading> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
<CText :mt="4">Vue makes front-end development a breeze.</c-text> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
</CBox> | ||||||
<CBox :p="5" shadow="md" border-width="1px"> | ||||||
<CHeading>Go Nuxt!</c-heading> | ||||||
D-Lite marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
<CText :mt="4">Nuxt makes writing Vue even easier.</c-text> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
</CBox> | ||||||
</CStack> | ||||||
``` | ||||||
|
||||||
## Stack items horizontally | ||||||
|
||||||
You can stack the items horizontally either: | ||||||
|
||||||
- By passing the `is-inline` prop or `direction` and set it to `row` to the `CStack` component. | ||||||
|
||||||
::showcase | ||||||
::horizontal-stack | ||||||
:: | ||||||
:: | ||||||
|
||||||
```html | ||||||
<CStack :spacing="5" is-inline> | ||||||
<CBox :p="5" shadow="md" border-width="1px"> | ||||||
<CHeading>See the Vue</c-heading> | ||||||
D-Lite marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
<CText :mt="4">Vue makes front-end development a breeze.</c-text> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
</CBox> | ||||||
<CBox :p="5" shadow="md" border-width="1px"> | ||||||
<CHeading>Go Nuxt!</c-heading> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
<CText :mt="4">Nuxt makes writing Vue even easier.</c-text> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
</CBox> | ||||||
</CStack> | ||||||
``` | ||||||
|
||||||
- Using the `CHStack` component. | ||||||
|
||||||
::showcase | ||||||
::horizontal-stack-two | ||||||
:: | ||||||
:: | ||||||
|
||||||
```html | ||||||
<CHStack :spacing="5"> | ||||||
<CBox :p="5" shadow="md" border-width="1px"> | ||||||
<CHeading>See the Vue</c-heading> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
<CText :mt="4">Vue makes front-end development a breeze.</c-text> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
</CBox> | ||||||
<CBox :p="5" shadow="md" border-width="1px"> | ||||||
<CHeading>Go Nuxt!</c-heading> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
<CText :mt="4">Nuxt makes writing Vue even easier.</c-text> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
</CBox> | ||||||
</CHStack> | ||||||
``` | ||||||
|
||||||
Optionally, you can use align and justify to adjust the alignment and distribution of the items. | ||||||
|
||||||
## Reverse display order of items | ||||||
|
||||||
Set `direction` to `row-reverse` or `column-reverse`. | ||||||
|
||||||
::showcase | ||||||
::reverse-stack | ||||||
:: | ||||||
:: | ||||||
|
||||||
```html | ||||||
<CStack :spacing="5" is-reversed> | ||||||
<CBox :p="5" shadow="md" border-width="1px"> | ||||||
<CHeading>See the Vue</c-heading> | ||||||
D-Lite marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
<CText :mt="4">Vue makes front-end development a breeze.</c-text> | ||||||
D-Lite marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
</CBox> | ||||||
<CBox :p="5" shadow="md" border-width="1px"> | ||||||
<CHeading>Go Nuxt!</c-heading> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
<CText :mt="4">Nuxt makes writing Vue even easier.</c-text> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
</CBox> | ||||||
</CStack> | ||||||
``` | ||||||
|
||||||
### Stacking HTML elements | ||||||
|
||||||
::showcase | ||||||
::html-stack | ||||||
:: | ||||||
:: | ||||||
|
||||||
```html | ||||||
<CStack :spacing="4"> | ||||||
<CText>Chakra component 1</CText> | ||||||
<p>HTML paragraph element</p> | ||||||
<h3>HTML heading element</h3> | ||||||
<CText>Chakra component 2</c-text> | ||||||
D-Lite marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
</CStack> | ||||||
``` | ||||||
|
||||||
## Props | ||||||
|
||||||
| Name | Type | Default | Description | | ||||||
|------------------|-----------------------------|---------|---------------------------------------------------------------------------------------------------------------------------------------| | ||||||
| `isInline` | `boolean` | false | If `true` the items will be stacked horizontally. | | ||||||
| `direction` | `FlexProps["flexDirection"]` | | The direction to stack the items. | | ||||||
| `spacing` | `StyledSystem.MarginProps` | | The space between each stack item | | ||||||
| `align` | `FlexProps["alignItems"]` | | The alignment of the stack item. Similar to `align-items` | | ||||||
| `justify` | `FlexProps["justifyContent"]` | | The distribution of the stack item. Similar to `justify-content` | | ||||||
| `shouldWrapChildren` | `boolean` | false | If `true`, the children will be wrapped in a `Box` with `display: inline-block`, and the Box will take the spacing props | | ||||||
| `divider` | `boolean` | false | If `true`, the stack items will be divided by a straight line | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could
Flex
be changed intoCFlex
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.