Column List Layout คือ view ที่ใช้เรียง children view ในแนวตั้ง
import styled from "styled-components";
export default function ListColumn({
children,
className,
style,
padding,
margin,
reversed,
justify = "center",
align = "center",
isWrap,
width,
height,
display = "flex",
}) {
return (
<Styled
className={className}
style={style}
$padding={padding}
$margin={margin}
$reversed={reversed}
$justify={justify}
$align={align}
$isWrap={isWrap}
$width={width}
$height={height}
$display={display}
>
{children}
</Styled>
);
}
const Styled = styled.div`
display: ${({ $display }) => $display};
flex-wrap: ${({ $isWrap }) => ($isWrap ? "wrap" : "nowrap")};
flex-direction: ${({ $reversed }) =>
!$reversed ? "column" : "column-reverse"};
justify-content: ${({ $justify }) => $justify};
align-items: ${({ $align }) => $align};
width: ${({ $width }) => $width};
height: ${({ $height }) => $height};
padding: ${({ $padding }) => $padding};
margin: ${({ $margin }) => $margin};
`;
import Box from "../../example/Box";
import ListColumnfrom "../../layout/ListColumn";
export default function TestView() {
return (
<div className="test-view">
<ListColumn>
<Box
width={"50px"}
height={"50px"}
marginBottom={"10px"}
backgroundColor={"var(--primary)"}
/>
<Box
width={"50px"}
height={"50px"}
marginBottom={"10px"}
backgroundColor={"var(--primary)"}
/>
<Box
width={"50px"}
height={"50px"}
marginBottom={"10px"}
backgroundColor={"var(--primary)"}
/>
<Box
width={"50px"}
height={"50px"}
marginBottom={"10px"}
backgroundColor={"var(--primary)"}
/>
</ListColumn>
</div>
);
}
Property | Description | Type | Default |
---|---|---|---|
children | children views | ReactElement | |
className | ใช้กำหนดลักษณะเฉพาะของ view | string | |
style | inline style ของ view | CSSProperties | |
padding | พื้นที่ว่างระหว่างเส้นขอบของ view และ เนื้อหาของ view | string | |
margin | พื้นที่ว่างระหว่างขอบนอกสุดของ view และ view อื่น | string | |
reversed | เมื่อกำหนด true จะทำการสลับลำดับ children views ไปในทิศตรงกันข้าม | boolean | |
justify | ลักษณะการเรียงตัวของ children views ในแนวแกนหลัก | string | "center" |
align | ลักษณะการเรียงตัวของ children views ในแนวแกนตรงข้าม | string | "center" |
isWrap | เมื่อกำหนด true จะทำการเรียง children views ขึ้นบรรทัดใหม่เมื่อความกว้างของ view ไม่พอ | boolean | |
width | ความกว้างภายในเนื้อหาของ view | string | |
height | ความสูงภายในเนื้อหาของ view | string | |
display | คุณลักษณะในการแสดงผล เช่น flex และ inline flex | string | "flex" |