Box

This component is used to define the layout of a child component. It can also include a box as a child component.

Request {#box-parameter}

ParameterTypeRequiredDescription
typestringYSet this parameter to box.
layoutstringYComponent layout direction in the box.
For more information, see Layout direction of components.
contentsarray of objectsYComponents of the box. You can add the following types of components:

• If the layout property is horizontal or vertical:
box, button, image, text, separator, filler
• If the layout property is baseline:
icon, text, filler

The added components are displayed in the order specified in the array.
backgroundColorstringNBlock background color. You can set an alpha channel (transparency) as well as an RGB color. Set a hex color code (e.g. #RRGGBBAA).

The default value is #00000000.
borderColorstringNBorder color Set a hex color code.
borderWidthstringNBorder width. You can enter a pixel value directly, or specify one of the following values: none, light, normal, medium, semi-bold, and bold.

none does not set a border while the other values set a border, with the border width increasing in the order they are listed.
cornerRadiusstringNSet the border corners to be rounded. You can enter a pixel value directly, or specify one of the following values: none, xs, sm, md, lg, xl, and xxl.

none does not round the border corners while the other values do, with the radius increasing in the order they are listed.

The default value is none.
widthstringNBox width. For more information, see Box width.
heightstringNBox height. For more information, see Box height.
flexnumberNThe proportion of the width or height of the components within the parent component. For more information, see Width and height of components.
spacingstringNThe minimum space between components in the box. The default value is none. For more information, see spacing.
marginstringNThe minimum space between a specific component and the previous component in the parent component. For more information, see margin.
paddingAllstringNThe space between the box border and the component added to the box. For more information, see Box padding.
paddingTopstringNThe space between the upper border of the box and the upper border of the component added to the box. For more information, see Box padding.
paddingBottomstringNThe space between the lower border of the box and the lower border of the component added to the box. For more information, see Box padding.
paddingStartstringNThe space between the left border of the box and the left border of the component added to the box. For more information, see Box padding.
paddingEndstringNThe space between the right border of the box and the right border of the component added to the box. For more information, see Box padding.
positionstringNThe position of the box. Specify one of the following values:

• relative: Uses the previous box as the reference point.
• absolute: Uses the upper left corner of the parent component as the reference point.

The default value is relative. For more information, see Offset.
offsetTopstringNTop offset. For more information, see Offset.
offsetBottomstringNBottom offset. For more information, see Offset.
offsetStartstringNLeft offset. For more information, see Offset.
offsetEndstringNRight offset. For more information, see Offset.
actionobjectNThe action that occurs when the box is tapped. Specify an action object.

Request example {#box-request-example}

{  "type": "bubble",  "size": "kilo",  "body": {    "type": "box",    "layout": "vertical",    "contents": [      {        "type": "text",        "text": "Welcome to the team!",        "color": "#222222",        "weight": "bold",        "size": "md",        "align": "center"      },      {        "type": "box",        "layout": "vertical",        "contents": [          {            "type": "image",            "url": "https://developers.worksmobile.com/image/en/bot/message_type/06-thomas-business-hr-staff.png",            "size": "sm",            "aspectMode": "cover",            "align": "center"          }        ],        "margin": "xxl",        "cornerRadius": "50px",        "borderWidth": "1px",        "borderColor": "#22222220",        "height": "60px",        "width": "60px",        "offsetStart": "85px",        "offsetEnd": "85px"      },      {        "type": "text",        "text": "Kyle Baron",        "weight": "bold",        "size": "lg",        "margin": "md",        "align": "center"      },      {        "type": "box",        "layout": "baseline",        "contents": [          {            "type": "text",            "text": "kylebaron@designer.com",            "size": "sm",            "color": "#666666",            "wrap": true,            "align": "center"          }        ]      },      {        "type": "text",        "text": "Please edit your detail information.",        "color": "#aaaaaa",        "size": "sm",        "wrap": true,        "align": "center",        "margin": "lg"      }    ]  },  "footer": {    "type": "box",    "layout": "vertical",    "spacing": "sm",    "contents": [      {        "type": "button",        "style": "primary",        "height": "sm",        "action": {          "type": "uri",          "label": "Edit Profile",          "uri": "https://line-works.com"        },        "color": "#2432AB"      }    ],    "flex": 0  }}