Flex Message json 和發出效果
function getMultiColumnJson() {
return {
"type": "bubble",
"size": "mega",
"header": {
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "text",
"text": "雙欄明細資訊",
"color": "#BFDBFE",
"size": "xs",
"weight": "bold"
},
{
"type": "text",
"text": "實戰工作坊入場憑證",
"color": "#FFFFFF",
"size": "lg",
"weight": "bold",
"margin": "xs"
}
]
},
"body": {
"type": "box",
"layout": "vertical",
"spacing": "md",
"contents": [
{
"type": "text",
"text": "LineBot × GAS 自動化實戰班",
"weight": "bold",
"size": "md",
"color": "#0F172A",
"wrap": true
},
{
"type": "separator",
"margin": "md",
"color": "#E2E8F0"
},
{
"type": "box",
"layout": "vertical",
"margin": "md",
"spacing": "sm",
"contents": [
{
"type": "box",
"layout": "horizontal",
"contents": [
{
"type": "text",
"text": "活動日期",
"size": "sm",
"color": "#64748B",
"flex": 1
},
{
"type": "text",
"text": "2026/11/15 (日) 14:00",
"size": "sm",
"color": "#1E293B",
"weight": "bold",
"flex": 2,
"align": "end"
}
]
},
{
"type": "box",
"layout": "horizontal",
"contents": [
{
"type": "text",
"text": "上課地點",
"size": "sm",
"color": "#64748B",
"flex": 1
},
{
"type": "text",
"text": "台北市 OO 區 XX 路 ZZ 號",
"size": "sm",
"color": "#1E293B",
"flex": 2,
"align": "end",
"wrap": true
}
]
},
{
"type": "box",
"layout": "horizontal",
"contents": [
{
"type": "text",
"text": "報到序號",
"size": "sm",
"color": "#64748B",
"flex": 1
},
{
"type": "text",
"text": "#GAS-888",
"size": "sm",
"color": "#2563EB",
"weight": "bold",
"flex": 2,
"align": "end"
}
]
}
]
},
{
"type": "separator",
"margin": "md",
"color": "#E2E8F0"
},
{
"type": "text",
"text": "排版技巧:利用垂直排版容器搭配水平排版容器,即可做出對齊資訊欄位",
"size": "xs",
"color": "#94A3B8",
"wrap": true,
"margin": "md"
}
]
},
"styles": {
"header": {
"backgroundColor": "#7C3AED"
}
}
}
}
巢狀容器
在垂直排版容器 (下圖綠色框) 內放入多個水平排版容器 (下圖黃色框),水平排版容器內放置文字標籤,藉此來顯示雙欄位文字資訊
屬性 flex
flex 則是決定水平排版容器內的文字標籤佔整個水平空間比例,以該例子來說,左側文字標籤設定 flex: 1 、右側文字標籤設定 flex: 2,所以水平空間總比例為 3 ,左側文字標籤代表佔 1/3、右側文字標籤代表佔 2/3
















