diff --git a/docs/pages/kimg.vue b/docs/pages/kimg.vue
index 1a93b70d7..ec2d24edb 100644
--- a/docs/pages/kimg.vue
+++ b/docs/pages/kimg.vue
@@ -198,6 +198,70 @@
/>
+
+
Slots
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Top left
+
+
+
+
+
+
+
+
+
+ Top left
+
+
+
+
+
+
diff --git a/lib/KImg.vue b/lib/KImg.vue
index 721b852e1..55ba157c6 100644
--- a/lib/KImg.vue
+++ b/lib/KImg.vue
@@ -7,8 +7,27 @@
:alt="alternativeText"
:style="imgStyles"
>
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -137,6 +156,24 @@
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`
+ */
+ backgroundColor: {
+ type: String,
+ required: false,
+ default: null,
+ },
},
computed: {
ratio() {
@@ -149,7 +186,8 @@
return {
rootContainer: {
display: 'block',
- backgroundColor: this.$themePalette.grey.v_200,
+ position: 'relative',
+ backgroundColor: this.backgroundColor,
height: this.validateAndFormatUnits(this.height),
width: this.validateAndFormatUnits(this.width),
maxHeight: this.validateAndFormatUnits(this.maxHeight),
@@ -162,6 +200,8 @@
},
img: {
display: 'block',
+ position: 'relative',
+ zIndex: '1',
},
};
},
@@ -264,6 +304,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');
}