SusImg

Image host with sizing, cover crop, rounded corners, and load / error hooks.
Package
SusKit · Atoms (commercial)
Props
| Name | Type | Default | |
|---|---|---|---|
Src | Prop<string> | "" | |
LazySrc | Prop<string> | "" | |
Alt | Prop<string> | "" | |
Height | Prop<float> | 0f | |
MaxHeight | Prop<float> | 0f | |
Width | Prop<float> | 0f | |
MaxWidth | Prop<float> | 0f | |
Cover | Prop<bool> | false | |
Stretch | Prop<bool> | false | |
Anchor | Prop<string> | "center" | |
Rounded | Prop<string> | "" | |
Gradient | Prop<string> | "" | |
AspectRatio | Prop<float> | 0f | |
Fit | Prop<string> | "width" |
Slots
| Name |
|---|
placeholder |
error |
Events
| Name | Field | Payload |
|---|---|---|
Load | OnLoad | Texture2D |
Error | OnError | string |
Style hooks
USS class contract — override appearance without touching C#. States toggle via these classes:
sus-imgsus-img__errorsus-img__error-textsus-img__gradientsus-img__placeholdersus-img__placeholder-textsus-img__surfacesus-img--coversus-img--errorsus-img--rounded-0sus-img--rounded-circlesus-img--rounded-lgsus-img--rounded-mdsus-img--rounded-pillsus-img--rounded-smsus-img--rounded-xssus-img--stretch
Usage
xml
<template>
<sus:SusImg Src="portraits/hero"
Alt="Hero portrait"
Cover="true"
Rounded="md"
AspectRatio="1"
@load="OnLoaded"
@error="OnFailed" />
</template>
<script>
void OnLoaded(Texture2D tex) { /* … */ }
void OnFailed(string reason) { /* … */ }
</script>csharp
var img = new SusImg();
img.Src.Value = "ui/banner";
img.Cover.Value = true;
img.MaxHeight.Value = 180f;
img.OnError += msg => { /* … */ };Notes
LazySrcloads after first paint when set.- Slots
placeholder/errorcustomize the empty and failed states.