-
Notifications
You must be signed in to change notification settings - Fork 7
Container component #37
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
Open
D-Lite
wants to merge
4
commits into
chakra-ui:main
Choose a base branch
from
D-Lite:container
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<template> | ||
<c-container maxW='2xl' bg='blue.600' centerContent> | ||
<c-box padding='4' bg='blue.400' color='black' maxW='md'> | ||
There are many benefits to a joint design and development system. Not only | ||
does it bring benefits to the design team, but it also brings benefits to | ||
engineering teams. It makes sure that our experiences have a consistent look | ||
and feel, not just in our design specs, but in production. | ||
</c-box> | ||
</c-container> | ||
</template> | ||
|
||
<script setup> | ||
import { CContainer, CBox } from '@chakra-ui/vue-next'; | ||
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<template> | ||
<c-v-stack w="2xl" align-items="center"> | ||
<c-container maxW='md' bg='blue.600' color='white'> | ||
"md" Container | ||
</c-container> | ||
<c-container maxW='550px' bg='purple.600' color='white'> | ||
"550px" Container | ||
</c-container> | ||
<c-container maxW='container.sm' bg='green.400' color='#262626'> | ||
"container.sm" Container | ||
</c-container> | ||
</c-v-stack> | ||
</template> | ||
|
||
<script setup> | ||
import { CContainer, CVStack } from '@chakra-ui/vue-next'; | ||
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<template> | ||
<c-container> | ||
There are many benefits to a joint design and development system. Not only | ||
does it bring benefits to the design team, but it also brings benefits to | ||
engineering teams. It makes sure that our experiences have a consistent look | ||
and feel, not just in our design specs, but in production | ||
</c-container> | ||
</template> | ||
|
||
<script setup> | ||
import { CContainer } from '@chakra-ui/vue-next'; | ||
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
--- | ||
title: Container | ||
description: | ||
Container component is used to constrain a content's width to the current breakpoint, while keeping it fluid. | ||
version: 2.0+ | ||
--- | ||
|
||
# Container | ||
|
||
Containers are used to constrain a content's width to the current breakpoint, while keeping it fluid. | ||
|
||
## Import | ||
|
||
```js | ||
import { CContainer } from '@chakra-ui/vue-next' | ||
``` | ||
|
||
## Usage | ||
|
||
To contain any piece of content, wrap it in the `Container` component. | ||
|
||
::showcase | ||
::simple-container | ||
:: | ||
:: | ||
|
||
```html | ||
<c-container> | ||
There are many benefits to a joint design and development system. Not only | ||
does it bring benefits to the design team, but it also brings benefits to | ||
engineering teams. It makes sure that our experiences have a consistent look | ||
and feel, not just in our design specs, but in production | ||
</c-container> | ||
``` | ||
|
||
### Container Size | ||
|
||
By default, the `Container` component sets the `maxWidth` of the content to 60 characters (`60ch`) but you can customize this by passing custom `maxWidth` values or changing the size tokens. | ||
|
||
> * About the default value: The `ch` unit is a relative unit defined by the rendered typeface's "0" character width. This width varies by the shape and style of the font. | ||
> * If you are curious about the reason for this default value of `60` characters, consider this explanation about [line length](https://betterwebtype.com/articles/2019/06/16/5-keys-to-accessible-web-typography/#line-length) from Better Web Type. | ||
|
||
::showcase | ||
::container-size | ||
:: | ||
:: | ||
|
||
```html | ||
<c-v-stack w="2xl" align-items="center"> | ||
<c-container maxW='md' bg='blue.600' color='white'> | ||
D-Lite marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"md" Container | ||
</c-container> | ||
<c-container maxW='550px' bg='purple.600' color='white'> | ||
D-Lite marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"550px" Container | ||
</c-container> | ||
<c-container maxW='container.sm' bg='green.400' color='#262626'> | ||
D-Lite marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"container.sm" Container | ||
</c-container> | ||
</c-v-stack> | ||
``` | ||
|
||
### Centering the children | ||
|
||
In some cases, the width of the content can be smaller than the container's width. You can use the `centerContent` prop to center the content. It renders a flexbox with `flexDirection` set to `column` and `alignItems` set to `center`. | ||
D-Lite marked this conversation as resolved.
Show resolved
Hide resolved
|
||
::showcase | ||
::container-center | ||
:: | ||
|
||
```html | ||
<c-container maxW='2xl' bg='blue.600' centerContent> | ||
D-Lite marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<c-box padding='4' bg='blue.400' color='black' maxW='md'> | ||
D-Lite marked this conversation as resolved.
Show resolved
Hide resolved
|
||
There are many benefits to a joint design and development system. Not only | ||
does it bring benefits to the design team, but it also brings benefits to | ||
engineering teams. It makes sure that our experiences have a consistent look | ||
and feel, not just in our design specs, but in production. | ||
</c-box> | ||
</c-container> | ||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.