@econnect/webcomponents-library
Documentation
Styleguide
Documentation
Styleguide
  • Getting Started

    • Installation
    • Patch Notes
    • Styleguide
  • Styling

    • e-connect colors
  • UI Components

    • Form

      • Search Field
      • Form Field
      • Forms
    • Filter

      • Filter
      • Search Filter
    • Grid

      • Grid
      • Grid Row
    • Inputs

      • File Input
      • Input Checkbox
      • Input Dropdown
      • Input Date
      • Input Date Time
      • Input Date Time Local
      • Input File
      • Input Label
      • Input Multi Select
      • Input Number
      • Input Radio
      • Input Range
      • Input Select
      • Input Switch
      • Input Slider
      • Input Text
      • Input TextArea
      • Input Time
      • Input Time Range
    • Controls

      • Booleans
      • Button
      • Checkboxes
      • Date Displays
      • Dropdown Lists
      • Text Displays
    • Headers

      • e-header
    • Cards

      • e-card
    • Images

      • Icon
      • Images
      • Flag Image
      • Hamburger
    • Iframe
    • Pager
    • Settings
    • Document Validation
    • Navigation

      • Navigation
      • Navigation Menu
      • Navigation Footer
      • Navigation Button
      • Navigation Button Item
      • Navigation Search Item

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>
Last Updated:: 10/10/24, 2:56 PM
Contributors: Antony Elfferich, AzureAD\MarcelLommers, Marcel Lommers
Prev
Button
Next
Date Displays