SDUI Playground
T

Text

Renders a single text label with typography, color, and alignment options.

type: "text"atomsleaf
Default (No Style)
Renders with body1Regular + neutral.900 fallbacks
Default text with no style applied
{
  "type": "text",
  "data": {
    "value": "Default text with no style applied"
  }
}

Quick Start

Quick Start
{
  "type": "text",
  "data": {
    "value": "value"
  }
}

Data Fields

FieldTypeDefaultDescription
valuerequired
stringText content to display

Style Fields

FieldTypeDefaultDescription
typography
typographyTypography style (predefined or overrides)
color
colorText color
text_align
enum
startcenterendjustify
Horizontal text alignment
max_lines
intMaximum number of lines (overflow ellipsis)
min_lines
intMinimum number of lines

Layout Fields

Parent Layout Fields

Examples

Heading 1
Bold 32sp heading
Product Title
{
  "type": "text",
  "data": {
    "value": "Product Title",
    "ui": {
      "style": {
        "typography": {
          "style": "heading1"
        },
        "color": {
          "palette": "neutral",
          "shade": 900
        }
      }
    }
  }
}
Body Regular
Standard body text
This is a regular body text used for descriptions and paragraphs in the app.
{
  "type": "text",
  "data": {
    "value": "This is a regular body text used for descriptions and paragraphs in the app.",
    "ui": {
      "style": {
        "typography": {
          "style": "body1Regular"
        },
        "color": {
          "palette": "neutral",
          "shade": 700
        }
      }
    }
  }
}
Caption SemiBold
Small caption text
Posted 2 hours ago
{
  "type": "text",
  "data": {
    "value": "Posted 2 hours ago",
    "ui": {
      "style": {
        "typography": {
          "style": "captionSemiBold"
        },
        "color": {
          "palette": "neutral",
          "shade": 500
        }
      }
    }
  }
}
textAlign: center
Center-aligned primary text on fill width
Welcome to 4Sale
{
  "type": "text",
  "data": {
    "value": "Welcome to 4Sale",
    "ui": {
      "style": {
        "typography": {
          "style": "heading2"
        },
        "color": {
          "palette": "primary",
          "shade": 500
        },
        "textAlign": "center"
      },
      "layout": {
        "size": {
          "width": "fill"
        }
      }
    }
  }
}
textAlign: end
Right-aligned text
250 KD
{
  "type": "text",
  "data": {
    "value": "250 KD",
    "ui": {
      "style": {
        "typography": {
          "style": "heading3"
        },
        "color": {
          "palette": "success",
          "shade": 500
        },
        "textAlign": "end"
      },
      "layout": {
        "size": {
          "width": "fill"
        }
      }
    }
  }
}
maxLines: 2
Truncated to 2 lines with ellipsis
This is a very long text that should be truncated after two lines. It demonstrates the maxLines property which adds an ellipsis at the end when the content overflows the available space. The remaining text is hidden.
{
  "type": "text",
  "data": {
    "value": "This is a very long text that should be truncated after two lines. It demonstrates the maxLines property which adds an ellipsis at the end when the content overflows the available space. The remaining text is hidden.",
    "ui": {
      "style": {
        "typography": {
          "style": "body2Regular"
        },
        "color": {
          "palette": "neutral",
          "shade": 700
        },
        "maxLines": 2
      },
      "layout": {
        "size": {
          "width": "fill"
        }
      }
    }
  }
}
maxLines: 1
Single-line truncation
Very long listing title that should definitely get truncated to just one single line
{
  "type": "text",
  "data": {
    "value": "Very long listing title that should definitely get truncated to just one single line",
    "ui": {
      "style": {
        "typography": {
          "style": "subtitle1"
        },
        "color": {
          "palette": "neutral",
          "shade": 900
        },
        "maxLines": 1
      },
      "layout": {
        "size": {
          "width": 250
        }
      }
    }
  }
}
Hex Color
Direct hex color (#FF5722)
Custom Hex Color
{
  "type": "text",
  "data": {
    "value": "Custom Hex Color",
    "ui": {
      "style": {
        "typography": {
          "style": "subtitle1"
        },
        "color": {
          "hex": "#FF5722"
        }
      }
    }
  }
}
Background + Corner Radius
Text with background pill badge
NEW
{
  "type": "text",
  "data": {
    "value": "NEW",
    "ui": {
      "style": {
        "typography": {
          "style": "captionBold"
        },
        "color": {
          "hex": "#FFFFFF"
        },
        "background": {
          "palette": "error",
          "shade": 500
        },
        "cornerRadius": 12
      },
      "layout": {
        "padding": {
          "horizontal": 10,
          "vertical": 4
        }
      }
    }
  }
}
Gradient Background
Text on a linear gradient
Featured
{
  "type": "text",
  "data": {
    "value": "Featured",
    "ui": {
      "style": {
        "typography": {
          "style": "subtitle2"
        },
        "color": {
          "hex": "#FFFFFF"
        },
        "background": {
          "start": {
            "palette": "primary",
            "shade": 500
          },
          "end": {
            "palette": "purple",
            "shade": 500
          },
          "angle": 0
        },
        "cornerRadius": 8
      },
      "layout": {
        "padding": {
          "horizontal": 12,
          "vertical": 6
        }
      }
    }
  }
}
Alpha (Opacity)
Semi-transparent text at 50% opacity
Semi-transparent
{
  "type": "text",
  "data": {
    "value": "Semi-transparent",
    "ui": {
      "style": {
        "typography": {
          "style": "heading3"
        },
        "color": {
          "palette": "primary",
          "shade": 500
        },
        "alpha": 0.5
      }
    }
  }
}
Rotation
Rotated 15 degrees
Rotated!
{
  "type": "text",
  "data": {
    "value": "Rotated!",
    "ui": {
      "style": {
        "typography": {
          "style": "subtitle1"
        },
        "color": {
          "palette": "error",
          "shade": 500
        },
        "rotation": -15
      }
    }
  }
}
Border
Text with border outline
Bordered Label
{
  "type": "text",
  "data": {
    "value": "Bordered Label",
    "ui": {
      "style": {
        "typography": {
          "style": "captionSemiBold"
        },
        "color": {
          "palette": "primary",
          "shade": 500
        },
        "border": {
          "width": 1,
          "color": {
            "palette": "primary",
            "shade": 200
          }
        },
        "cornerRadius": 6
      },
      "layout": {
        "padding": {
          "horizontal": 10,
          "vertical": 4
        }
      }
    }
  }
}
Fixed Size + Padding
Text in a fixed-size container with padding
Boxed Text
{
  "type": "text",
  "data": {
    "value": "Boxed Text",
    "ui": {
      "style": {
        "typography": {
          "style": "body2SemiBold"
        },
        "color": {
          "palette": "neutral",
          "shade": 800
        },
        "background": {
          "palette": "neutral",
          "shade": 50
        },
        "cornerRadius": 8
      },
      "layout": {
        "padding": {
          "all": 16
        },
        "size": {
          "width": 200,
          "height": 60
        }
      }
    }
  }
}
parentLayout: weight
Text with weight=1 inside a row (takes remaining space)
Label
Fills remaining space
{
  "type": "row",
  "data": {
    "children": [
      {
        "type": "text",
        "data": {
          "value": "Label",
          "ui": {
            "style": {
              "typography": {
                "style": "body2SemiBold"
              }
            }
          }
        }
      },
      {
        "type": "text",
        "data": {
          "value": "Fills remaining space",
          "ui": {
            "style": {
              "typography": {
                "style": "body2Regular"
              },
              "color": {
                "palette": "neutral",
                "shade": 500
              },
              "textAlign": "end",
              "background": {
                "palette": "primary",
                "shade": 50
              },
              "cornerRadius": 4
            },
            "layout": {
              "padding": {
                "horizontal": 8,
                "vertical": 4
              }
            },
            "parentLayout": {
              "weight": 1
            }
          }
        }
      }
    ],
    "ui": {
      "layout": {
        "spacing": 12,
        "crossAxis": "center",
        "size": {
          "width": "fill"
        }
      }
    }
  }
}

Production Patterns

Real patterns extracted from the 4Sale production API.

Listing Titlebody2SemiBold, neutral 900, clamped to 2 lines
Mercedes-Benz C300 2019
{
  "type": "text",
  "data": {
    "value": "Mercedes-Benz C300 2019",
    "ui": {
      "style": {
        "typography": {
          "style": "body2SemiBold"
        },
        "color": {
          "palette": "neutral",
          "shade": 900
        },
        "maxLines": 2,
        "minLines": 2
      }
    }
  }
}
Pricebody2SemiBold in primary 500
12,500 KD
{
  "type": "text",
  "data": {
    "value": "12,500 KD",
    "ui": {
      "style": {
        "typography": {
          "style": "body2SemiBold"
        },
        "color": {
          "palette": "primary",
          "shade": 500
        }
      }
    }
  }
}
AttributescaptionRegular, neutral 600, single line
Automatic · 45,000 km · White
{
  "type": "text",
  "data": {
    "value": "Automatic · 45,000 km · White",
    "ui": {
      "style": {
        "typography": {
          "style": "captionRegular"
        },
        "color": {
          "palette": "neutral",
          "shade": 600
        },
        "maxLines": 1
      }
    }
  }
}
Time AgocaptionRegular, neutral 500
2 hours ago
{
  "type": "text",
  "data": {
    "value": "2 hours ago",
    "ui": {
      "style": {
        "typography": {
          "style": "captionRegular"
        },
        "color": {
          "palette": "neutral",
          "shade": 500
        }
      }
    }
  }
}
Section Headersubtitle1, neutral 900 — section title
سيارات مستعملة
{
  "type": "text",
  "data": {
    "value": "سيارات مستعملة",
    "ui": {
      "style": {
        "typography": {
          "style": "subtitle1"
        },
        "color": {
          "palette": "neutral",
          "shade": 900
        }
      }
    }
  }
}
Badge / CountcaptionRegular, neutral 500 — listing count
١,٢٣٤ إعلان متاح
{
  "type": "text",
  "data": {
    "value": "١,٢٣٤ إعلان متاح",
    "ui": {
      "style": {
        "typography": {
          "style": "captionRegular"
        },
        "color": {
          "palette": "neutral",
          "shade": 500
        }
      }
    }
  }
}
Featured Price (Full Card)subtitle2, primary 500 — used in full-width cards
12,500 KD
{
  "type": "text",
  "data": {
    "value": "12,500 KD",
    "ui": {
      "style": {
        "typography": {
          "style": "subtitle2"
        },
        "color": {
          "palette": "primary",
          "shade": 500
        }
      }
    }
  }
}