diff --git a/docs/pages/kimg.vue b/docs/pages/kimg.vue
index 1a93b70d7..4c49fd63b 100644
--- a/docs/pages/kimg.vue
+++ b/docs/pages/kimg.vue
@@ -198,6 +198,24 @@
/>
+
+
Placeholder
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/KImg.vue b/lib/KImg.vue
index 721b852e1..ade7f2db5 100644
--- a/lib/KImg.vue
+++ b/lib/KImg.vue
@@ -2,13 +2,20 @@
+
-
+
+
+
+
+
+
+
@@ -137,6 +144,25 @@
default: 'centerInside', // needs to be duplicated rather than using ScaleTypes.CENTER_INSIDE, otherwise it doesn't render correctly in the auto-generated Props documentation
validator: isValidScaleType,
},
+ /**
+ * A color to be displayed instead or behind an image.
+ * It creates a background area which respects the dimensions
+ * set on the container.
+ *
+ * It can serve as (1) a color of the area surrounding an image when
+ * it's letterboxed, (2) creates a placeholder area displayed
+ * over the whole container when an image source is not provided,
+ * (3) creates a progressive loading experience as the colored background
+ * is displayed while an image is loading.
+ *
+ * Its default value is `$themePalette.grey.v_200`
+ */
+ // See `created` hook for an assignment of the default value
+ backgroundColor: {
+ type: String,
+ required: false,
+ default: null,
+ },
},
computed: {
ratio() {
@@ -149,7 +175,7 @@
return {
rootContainer: {
display: 'block',
- backgroundColor: this.$themePalette.grey.v_200,
+ backgroundColor: this.backgroundColor,
height: this.validateAndFormatUnits(this.height),
width: this.validateAndFormatUnits(this.width),
maxHeight: this.validateAndFormatUnits(this.maxHeight),
@@ -264,6 +290,9 @@
},
},
created() {
+ if (!this.backgroundColor) {
+ this.backgroundColor = this.$themePalette.grey.v_200;
+ }
if (!this.isDecorative && !this.altText) {
throw new Error('Missing required prop - provide altText or indicate isDecorative');
}