Checkboxes v1.0
The <e-checkbox> component is a component that can be used for .
Usage
An unavailable has attributes that must be provided,
<e-checkbox
id=''
label=''
:modelValue=''
/>
Attributes
id | Type: String | required
label | Type: String | Default:''
modelValue | Type: Boolean | Default:false
Examples
Below a few interactive examples of unavailable can be found.
Unchecked Checkbox
<e-checkbox
id='uncheckedCheckbox'
label='Try me!'
/>
Checked Checkbox
<e-checkbox
id='checkedCheckbox'
label='Try me!'
:modelValue='true'
/>
Source Code
e-checkbox.vue
<script setup lang="ts">
export type Props = {
value?: boolean;
id: string;
label?: string;
required?: boolean;
disabled?: boolean;
};
withDefaults(defineProps<Props>(), {
value: false,
label: '',
required: false,
disabled: false
});
const emit = defineEmits<{
(e: 'update:value', value: boolean): void;
}>();
const emitUpdate = (event: Event) => {
const target = event.target as HTMLInputElement;
emit('update:value', target.checked);
};
</script>
<template>
<label
class="e-checkbox"
:class="{
disabled: disabled
}"
:for="id"
:required="required"
>
<input
:id="id"
type="checkbox"
:checked="value"
:required="required"
:disabled="disabled"
@change="emitUpdate"
/>
{{ label }}
</label>
</template>
<style scoped lang="scss">
.e-checkbox {
text-indent: 10px;
font-family: var(--e-body-font-family);
font-size: 14px;
cursor: pointer;
overflow: hidden;
text-align: left;
text-overflow: ellipsis;
white-space: nowrap;
width: 80%;
&[required]::after {
content: '*';
padding-left: 2px;
color: var(--e-required);
font-weight: bold;
}
input {
width: fit-content;
cursor: pointer;
margin-left: 0;
margin-top: 4px;
}
&.disabled {
color: var(--e-disabled);
}
}
</style>