Nhảy tới nội dung

Box

Box là component giúp bao bọc các element giúp thêm khoảng cách giữa các element một cách dễ dàng theo spacing system của Zalo Mini App.

Ngoài ra box còn hỗ trợ tạo nhanh Flex Layout.

Properties

Box

NameTypeDefaultDescription
noSpaceboolean

Các element sẽ có margin: 0padding: 0

inlinebooleanfalse

Nhận giá trị true nếu muốn các element inline block

mnumber

Giá trị margin của box, nhận giá trị là level từ 0 đến 10, với giá trị margin tương ứng là level x 4px

pnumber

Giá trị padding của box, nhận giá trị là level từ 0 đến 10, với giá trị padding tương ứng là level x 4px

mtnumber

Giá trị margin top

mlnumber

Giá trị margin left

mbnumber

Giá trị margin bottom

mrnumber

Giá trị margin right

ptnumber

Giá trị padding top

plnumber

Giá trị padding left

pbnumber

Giá trị padding bottom

prnumber

Giá trị padding right

mxnumber

Giá trị margin left và margin right

mynumber

Giá trị margin top và margin bottom

pxnumber

Giá trị padding left và padding right

pynumber

Giá trị padding top và padding bottom

widthnumber

Chiều rộng của box

heightnumber

Chiều dài của box

verticalAlignVerticalAlignEnum

Giá trị vertical-align

textAlignstring

Giá trị text-align

flexboolean

Chuyển box sang flex layout

flexDirectionstring

Giá trị flex-direction

flexWrapstring

Giá trị flex-wrap

justifyContentstring

Giá trị justify-content

alignItemsstring

Giá trị align-items

alignContentstring

Giá trị align-content

childrenReact.ReactNode

ReactNode

Type

VerticalAlignEnum

NameDescription
"baseline"

The element is aligned with the baseline of the parent. This is default

"sub"

The element is aligned with the subscript baseline of the parent

"super"

The element is aligned with the superscript baseline of the parent

"top"

The element is aligned with the top of the tallest element on the line

"text-top"

The element is aligned with the top of the parent element's font

"middle"

The element is placed in the middle of the parent element

"bottom"

The element is aligned with the lowest element on the line

"text-bottom"

The element is aligned with the bottom of the parent element's font

"initial"

Sets this property to its default value

"inherit"

Inherits this property from its parent element

TextAlignEnum

NameDescription
"left"

text align left

"right"

text align right

"center"

text align center

"justify"

justify

"initial"

initital

"inherit"

inherit

Example

import React from "react";
import { Page, Box } from "zmp-ui";

function HomePage(props){
return (
<Page>
<Box m={1}>
<Button size="large">Button</Button>
</Box>
</Page>
);
}