Skip to content

Commit 22415f6

Browse files
committed
refactor(checkbox): Use Label class for suffix and prefix
1 parent 24f6df3 commit 22415f6

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

dev/pages/index.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ const schema = reactive(
5757
name: 'eu_citizen',
5858
id: 'eu',
5959
prefix: 'Are you a european citizen?',
60-
outerClass: 'col-6',
6160
},
6261
{
6362
$formkit: 'primeSelect',
@@ -68,7 +67,6 @@ const schema = reactive(
6867
optionValue: 'value',
6968
options,
7069
help: 'How often should we display a cookie notice?',
71-
outerClass: 'col-6',
7270
},
7371
],
7472
)

src/components/PrimeCheckbox.vue

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,22 @@ const props = defineProps({
2323
},
2424
})
2525
26-
const { hasPrefix, hasSuffix } = useFormKitSection(props.context)
26+
const { hasPrefix, hasSuffix, generateId } = useFormKitSection(props.context)
2727
2828
const { styleClass, handleInput, handleBlur } = useFormKitInput(props.context)
29+
30+
const generatedId = generateId()
2931
</script>
3032

3133
<template>
3234
<div class="p-formkit">
33-
<span v-if="hasPrefix" class="formkit-prefix">
35+
<label v-if="hasPrefix" :for="generatedId" class="formkit-prefix">
3436
{{ context?.prefix }}
35-
</span>
37+
</label>
3638
<Checkbox
3739
v-model="context._value"
3840
v-bind="context?.attrs"
39-
:input-id="context.id"
41+
:input-id="generatedId"
4042
:disabled="!!context?.disabled"
4143
:readonly="context?.attrs.readonly ?? false"
4244
:input-style="context?.attrs.style"
@@ -55,8 +57,8 @@ const { styleClass, handleInput, handleBlur } = useFormKitInput(props.context)
5557
@change="handleInput"
5658
@blur="handleBlur"
5759
/>
58-
<span v-if="hasSuffix" class="formkit-suffix">
60+
<label v-if="hasSuffix" :for="generatedId" class="formkit-suffix">
5961
{{ context?.suffix }}
60-
</span>
62+
</label>
6163
</div>
6264
</template>

0 commit comments

Comments
 (0)