diff --git a/.changeset/rotten-games-fly.md b/.changeset/rotten-games-fly.md
new file mode 100644
index 0000000000..bf5168e5c6
--- /dev/null
+++ b/.changeset/rotten-games-fly.md
@@ -0,0 +1,6 @@
+---
+"@gradio/label": patch
+"gradio": patch
+---
+
+feat:Fix `gr.Label` styling and a11y markup
diff --git a/js/label/Label.stories.svelte b/js/label/Label.stories.svelte
new file mode 100644
index 0000000000..a0765c8e11
--- /dev/null
+++ b/js/label/Label.stories.svelte
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
diff --git a/js/label/shared/Label.svelte b/js/label/shared/Label.svelte
index c85017a035..2821f77ef3 100644
--- a/js/label/shared/Label.svelte
+++ b/js/label/shared/Label.svelte
@@ -11,6 +11,13 @@
export let color: string | undefined = undefined;
export let selectable = false;
+
+ function get_aria_referenceable_id(elem_id: string): string {
+ // `aria-labelledby` interprets the value as a space-separated id reference list,
+ // so each single id should not contain any spaces.
+ // Ref: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-labelledby#benefits_and_drawbacks
+ return elem_id.replace(/\s/g, "-");
+ }
@@ -35,27 +42,35 @@
>
- -
+
-
{confidence_set.label}
- {#if value.confidences}
-
- -
- {Math.round(confidence_set.confidence * 100)}%
-
- {/if}
+
+ -
+ {Math.round(confidence_set.confidence * 100)}%
+
@@ -126,6 +141,7 @@
.text {
line-height: var(--line-md);
+ text-align: left;
}
.line {