Form
The container for different types of input elements
Examples
Form
Code
vue
<script setup lang="ts">
import { computed } from 'vue'
import { type BaseFormLayoutType } from '@point-hub/papp'
export interface Props {
modelValue: string
label?: string
description?: string
layout?: BaseFormLayoutType
required?: boolean
helpers?: string[]
errors?: string[]
}
const props = withDefaults(defineProps<Props>(), {
layout: 'horizontal',
required: false
})
const emit = defineEmits<{
(e: 'update:modelValue', value: string): void
}>()
const inputValue = computed({
set: (text: string) => {
emit('update:modelValue', text)
},
get: () => props.modelValue
})
</script>
<template>
<base-form
:label="props.label"
:layout="props.layout"
:description="props.description"
:required="props.required"
:helpers="props.helpers"
:errors="props.errors"
>
<input class="form-input border-simple" v-model="inputValue" />
</base-form>
</template>Form API
Types
ts
export type BaseFormLayoutType = 'vertical' | 'horizontal'Props
| Name | Type | Default | Description |
|---|---|---|---|
| id | string | Form id. | |
| label | string | Form label. | |
| description | string | Form description. | |
| layout | BaseFormLayoutType | horizontal | Form layout. |
| required | boolean | false | Form required indicator. |
| helpers | string[] | Form helper message. | |
| errors | string[] | Form error message. |
Slot
#default slot for rendering form content