List Row

Row List Layout คือ view ที่ใช้เรียง children view ในแนวนอน

Source Code

ReactJs styled components
Copy
import styled from "styled-components";
export default function ListRow({
  children,
  className,
  style,
  padding,
  margin,
  width,
  height,
  reversed,
  display = "flex",
  justify = "center",
  align = "center",
  isWrap,
}) {
  return (
    <Styled
      className={className}
      style={style}
      $padding={padding}
      $margin={margin}
      $width={width}
      $height={height}
      $reversed={reversed}
      $justify={justify}
      $align={align}
      $isWrap={isWrap}
      $display={display}
    >
      {children}
    </Styled>
  );
}

const Styled = styled.div`
  display: ${({ $display }) => $display};
  flex-wrap: ${({ isWrap }) => (isWrap ? "wrap" : "nowrap")};
  flex-direction: ${({ reversed }) => (!reversed ? "row" : "row-reverse")};
  justify-content: ${({ justify }) => justify};
  align-items: ${({ align }) => align};
  width: ${({ width }) => width};
  height: ${({ height }) => height};
  padding: ${({ padding }) => padding};
  margin: ${({ margin }) => margin};
`;

Usage

ReactJs Styled Components
Copy
import Box from "../../example/Box";
import ListRow from "../../layout/ListRow";

export default function TestView() {
  return (
    <div className="test-view">
      <ListRow>
        <Box
          width={"50px"}
          height={"50px"}
          marginRight={"10px"}
          backgroundColor={"var(--primary)"}
        />
        <Box
          width={"50px"}
          height={"50px"}
          marginRight={"10px"}
          backgroundColor={"var(--primary)"}
        />
        <Box
          width={"50px"}
          height={"50px"}
          marginRight={"10px"}
          backgroundColor={"var(--primary)"}
        />
        <Box
          width={"50px"}
          height={"50px"}
          marginRight={"10px"}
          backgroundColor={"var(--primary)"}
        />
      </ListRow>
    </div>
  );
}

Properties

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"

Requirements

styled-components

ยักซ่า (Yakxar)
สร้างสรรค์และแบ่งปันสื่อดิจิทัลง่ายๆ ที่นี่
© 2025 ยักซ่า (Yakxar)