Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Food Choice Field with custom formatting
{
"elmType": "div",
"style": {
"flex-wrap": "wrap",
"display": "flex"
},
"children": [
{
"elmType": "div",
"style": {
"box-sizing": "border-box",
"padding": "4px 8px 5px 8px",
"display": "flex",
"border-radius": "16px",
"height": "24px",
"align-items": "center",
"white-space": "nowrap",
"overflow": "hidden",
"margin": "4px 4px 4px 4px"
},
"attributes": {
"class": {
"operator": ":",
"operands": [
{
"operator": "==",
"operands": [
"@currentField",
"Pizza"
]
},
"sp-css-backgroundColor-red",
{
"operator": ":",
"operands": [
{
"operator": "==",
"operands": [
"@currentField",
"Burger"
]
},
"sp-css-backgroundColor-green",
{
"operator": ":",
"operands": [
{
"operator": "==",
"operands": [
"@currentField",
"Sushi"
]
},
"sp-css-backgroundColor-yellow",
{
"operator": ":",
"operands": [
{
"operator": "==",
"operands": [
"@currentField",
""
]
},
"",
"sp-field-borderAllRegular sp-field-borderAllSolid sp-css-borderColor-neutralSecondary"
]
}
]
}
]
}
]
}
},
"children": [
{
"elmType": "span",
"style": {
"line-height": "16px",
"height": "14px"
},
"attributes": {
"iconName": {
"operator": ":",
"operands": [
{
"operator": "==",
"operands": [
"@currentField",
"Pizza"
]
},
"",
{
"operator": ":",
"operands": [
{
"operator": "==",
"operands": [
"@currentField",
"Burger"
]
},
"",
{
"operator": ":",
"operands": [
{
"operator": "==",
"operands": [
"@currentField",
"Sushi"
]
},
"",
{
"operator": ":",
"operands": [
{
"operator": "==",
"operands": [
"@currentField",
""
]
},
"",
""
]
}
]
}
]
}
]
}
}
},
{
"elmType": "span",
"style": {
"overflow": "hidden",
"text-overflow": "ellipsis",
"padding": "0 3px"
},
"txtContent": "@currentField",
"attributes": {
"class": {
"operator": ":",
"operands": [
{
"operator": "==",
"operands": [
"@currentField",
"Pizza"
]
},
"",
{
"operator": ":",
"operands": [
{
"operator": "==",
"operands": [
"@currentField",
"Burger"
]
},
"",
{
"operator": ":",
"operands": [
{
"operator": "==",
"operands": [
"@currentField",
"Sushi"
]
},
"",
{
"operator": ":",
"operands": [
{
"operator": "==",
"operands": [
"@currentField",
""
]
},
"",
""
]
}
]
}
]
}
]
}
}
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment