-
Notifications
You must be signed in to change notification settings - Fork 7
docs(box): add box documentation #34
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:box
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,50 @@ | ||
<template> | ||
<c-box maxW="sm" border-width="1px" rounded="lg" overflow="hidden"> | ||
<c-image :src="property.imageUrl" :alt="property.imageAlt" /> | ||
<c-box p="6"> | ||
<c-box d="flex" align-items="baseline"> | ||
<c-badge rounded="full" px="2" variant-color="green"> | ||
New | ||
</c-badge> | ||
<c-box color="gray.500" font-weight="semibold" letter-spacing="wide" font-size="xs" text-transform="uppercase" | ||
ml="2"> | ||
{{ property.beds }} beds • {{ property.baths }} baths | ||
</c-box> | ||
</c-box> | ||
<c-box mt="1" font-weight="semibold" as="h4" line-height="tight" is-truncated> | ||
{{ property.title }} | ||
</c-box> | ||
<c-box> | ||
{{ property.formattedPrice }} | ||
<c-box as="span" color="gray.600" fontSize="sm"> | ||
/ wk | ||
</c-box> | ||
</c-box> | ||
<c-box d="flex" mt="2" align-items="center"> | ||
<c-icon v-for="(_, i) in Array(5).fill('')" name="star" :key="i" | ||
:color="i < property.rating ? 'green.500' : 'gray.300'" /> | ||
<c-box as="span" ml="2" color="gray.600" font-size="sm"> | ||
{{ property.reviewCount }} reviews | ||
</c-box> | ||
</c-box> | ||
</c-box> | ||
</c-box> | ||
</template> | ||
|
||
<script setup> | ||
import { reactive } from 'vue' | ||
|
||
const property = reactive( | ||
{ | ||
imageUrl: "https://bit.ly/2Z4KKcF", | ||
imageAlt: "Rear view of modern home with pool", | ||
beds: 3, | ||
baths: 2, | ||
title: "Modern home in city center in the heart of historic Los Angeles", | ||
formattedPrice: "$1,900.00", | ||
reviewCount: 34, | ||
rating: 4, | ||
} | ||
) | ||
|
||
</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,5 @@ | ||
<template> | ||
<c-box as="button" rounded="md" bg="tomato" color="white" px="4" h="8"> | ||
Button | ||
</c-box> | ||
</template> |
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,11 @@ | ||
<template> | ||
<c-box bg="tomato" w="100%" p="4" color="white"> | ||
This is the Box | ||
</c-box> | ||
</template> | ||
|
||
<script setup> | ||
import { | ||
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,110 @@ | ||
--- | ||
title: Box | ||
description: Box component | ||
version: 2.0+ | ||
--- | ||
# Box | ||
|
||
Box is the most abstract component on top of which all other `@chakra-ui/vue` components are built. By default, it renders a `div` element | ||
|
||
## Import | ||
|
||
Chakra UI Vue exports 5 accordion-related components. | ||
```js | ||
import { CBox } from "@chakra-ui/vue-next" | ||
``` | ||
|
||
## Usage | ||
|
||
The Box component is useful because it helps with three common use cases: | ||
- Create responsive layouts with ease. | ||
- Provide a shorthand way to pass styles via props (`bg` instead of `backgroundColor`). | ||
- Compose new component and allow for override using the `as` prop. | ||
|
||
::showcase | ||
:simple-box | ||
:: | ||
|
||
|
||
```html | ||
<c-box bg="tomato" w="100%" p="4" color="white"> | ||
This is the Box | ||
</c-box> | ||
D-Lite marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
## Composition with `CBox` | ||
|
||
::showcase | ||
:air-bnb-box{width=full} | ||
:: | ||
|
||
```html | ||
<template> | ||
<c-box maxW="sm" border-width="1px" rounded="lg" overflow="hidden"> | ||
<c-image :src="property.imageUrl" :alt="property.imageAlt" /> | ||
<c-box p="6"> | ||
<c-box d="flex" align-items="baseline"> | ||
<c-badge rounded="full" px="2" variant-color="green"> | ||
New | ||
</c-badge> | ||
<c-box color="gray.500" font-weight="semibold" letter-spacing="wide" font-size="xs" text-transform="uppercase" | ||
ml="2"> | ||
{{ property.beds }} beds • {{ property.baths }} baths | ||
</c-box> | ||
</c-box> | ||
<c-box mt="1" font-weight="semibold" as="h4" line-height="tight" is-truncated> | ||
{{ property.title }} | ||
</c-box> | ||
<c-box> | ||
{{ property.formattedPrice }} | ||
<c-box as="span" color="gray.600" fontSize="sm"> | ||
/ wk | ||
</c-box> | ||
</c-box> | ||
<c-box d="flex" mt="2" align-items="center"> | ||
<c-icon v-for="(_, i) in Array(5).fill('')" name="star" :key="i" | ||
:color="i < property.rating ? 'green.500' : 'gray.300'" /> | ||
<c-box as="span" ml="2" color="gray.600" font-size="sm"> | ||
{{ property.reviewCount }} reviews | ||
</c-box> | ||
</c-box> | ||
</c-box> | ||
</c-box> | ||
</template> | ||
|
||
<script setup> | ||
import { reactive } from 'vue' | ||
|
||
const property = reactive( | ||
{ | ||
imageUrl: "https://bit.ly/2Z4KKcF", | ||
imageAlt: "Rear view of modern home with pool", | ||
beds: 3, | ||
baths: 2, | ||
title: "Modern home in city center in the heart of historic Los Angeles", | ||
formattedPrice: "$1,900.00", | ||
reviewCount: 34, | ||
rating: 4, | ||
} | ||
) | ||
|
||
</script> | ||
``` | ||
|
||
## as prop | ||
|
||
You can use the `as` prop to change the element render, just like styled-components. | ||
|
||
::showcase | ||
:as-box{width-full} | ||
:: | ||
|
||
```html | ||
<c-box as="button" rounded="md" bg="tomato" color="white" px="4" h="8"> | ||
Button | ||
</c-box> | ||
``` | ||
|
||
## Props | ||
|
||
See all `CBox` props in the [Style props page](/styled-system/style-props) |
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.