Skip to content

Commit da36323

Browse files
committed
✨ Add HTML support to switch toggle label
1 parent 22eb1d0 commit da36323

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

src/components/Switch/Switch.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ const styleVariables = classNames([
3838
<label class:list={classes} style={styleVariables}>
3939
<input type="checkbox" checked={toggled} disabled={disabled} {...rest} />
4040
<span class={styles.toggle}></span>
41-
{label && <span class={styles.label}>{label}</span>}
41+
{label && <span class={styles.label} set:html={label} />}
4242
</label>

src/components/Switch/Switch.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@
4444
/>
4545
<span class={styles.toggle}></span>
4646
{#if label}
47-
<span class={styles.label}>{label}</span>
47+
<span class={styles.label}>{@html label}</span>
4848
{/if}
4949
</label>

src/components/Switch/Switch.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ const Switch = ({
4242
{...rest}
4343
/>
4444
<span className={styles.toggle}></span>
45-
{label && <span className={styles.label}>{label}</span>}
45+
{label && (
46+
<span
47+
className={styles.label}
48+
dangerouslySetInnerHTML={{ __html: label }}
49+
/>
50+
)}
4651
</label>
4752
)
4853
}

src/pages/components/switch.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const sections = getSections({
4949
</ComponentWrapper>
5050

5151
<ComponentWrapper title="With label">
52-
<section.component label="Toggle me" />
52+
<section.component label="Toggle <u>me</u>" />
5353
</ComponentWrapper>
5454

5555
<ComponentWrapper title="With label on left">

0 commit comments

Comments
 (0)