Skip to main content
Version: v1 (Current)

Form Element

Generated from public Vue/TypeScript exports by pnpm docs:generate. Edit source comments and stories to update this reference. Types describe the declared API; browser/device constraints are covered in the guides. This catalog reflects source commit fc6bfb108634735f1657e533206c3f8702ad357d; match your installed package and typed manifest before using an export. Source review does not establish registry-release availability.

FormElement​

import { FormElement } from '@gxp-dev/app-ui'

Repository source

Props​

NameTypeRequired / defaultDescription
typeFormElementTypeRequired—
namestringRequired—
labelstring | undefined——
placeholderstring | undefined——
helpstring | undefined——
tooltipstring | undefined——
requiredboolean | undefined——
disabledboolean | undefined——
optionsFormElementOption[] | undefined[]—
defaultValueunknown——
validationFormElementValidation | undefined——
minnumber | undefined——
maxnumber | undefined——
stepnumber | undefined——
rowsnumber | undefined——
multipleboolean | undefined——
acceptstring | undefined——
when((values: Record<string, unknown>) => boolean) | undefined——
controlPropsRecord<string, unknown> | undefined——
modelValueunknown——

Events​

NameTypeRequired / defaultDescription
update:modelValue[value: unknown]——

Slots​

NameTypeRequired / defaultDescription
label{}——
help{}——
control{ componentField: ComponentFieldBindingObject<any>; value: any; handleChange: (e: unknown, shouldValidate?: boolean | undefined) => void; errors: string[]; }——

Examples​

These are authored Storybook excerpts, not complete standalone modules. Relative imports refer to the story file; in an app import public components from @gxp-dev/app-ui. Default meta arguments are applied before each story.

Default​

import type { Meta, StoryObj } from '@storybook/vue3-vite'
import { useForm } from 'vee-validate'
import * as z from 'zod'
import { FormElement } from '.'
import { Button } from '@/components/ui/button'
const defaultArgs = {
type: 'text',
name: 'field',
label: 'Field label',
}
{
args: {
type: 'text',
name: 'first_name',
label: 'First name',
placeholder: 'Jane',
help: 'As it should appear on your badge.',
tooltip: 'We print this on your event badge.',
required: true,
},
}

KitchenSink​

import type { Meta, StoryObj } from '@storybook/vue3-vite'
import { useForm } from 'vee-validate'
import * as z from 'zod'
import { FormElement } from '.'
import { Button } from '@/components/ui/button'
const defaultArgs = {
type: 'text',
name: 'field',
label: 'Field label',
}
{
render: () => ({
components: { FormElement, Button },
setup() {
const form = useForm()
const onSubmit = form.handleSubmit((values) => {
console.log('values', values)
})
const options = [
{ label: 'Small', value: 'sm' },
{ label: 'Medium', value: 'md' },
{ label: 'Large', value: 'lg' },
]
const stacks = [
{ label: 'Vue', value: 'vue', group: 'Frontend' },
{ label: 'React', value: 'react', group: 'Frontend' },
{ label: 'Laravel', value: 'laravel', group: 'Backend' },
]
return { onSubmit, options, stacks }
},
template: `
<form class="w-[28rem] space-y-5" novalidate @submit="onSubmit">
<FormElement type="text" name="name" label="Name" placeholder="Jane Doe" required />
<FormElement type="email" name="email" label="Email" tooltip="We never share it" required />
<FormElement type="number" name="guests" label="Guests" :min="0" :max="10" help="Including yourself" />
<FormElement type="textarea" name="bio" label="Bio" :rows="3" />
<FormElement type="select" name="size" label="T-shirt size" :options="options" required />
<FormElement type="autocomplete" name="stack" label="Favorite stack" :options="stacks" />
<FormElement type="multiselect" name="stacks" label="All your stacks" :options="stacks" />
<FormElement type="radio" name="meal" label="Meal" :options="[{label:'Veggie',value:'v'},{label:'Meat',value:'m'}]" />
<FormElement type="checkbox-group" name="days" label="Attending days" :options="[{label:'Mon',value:'mon'},{label:'Tue',value:'tue'},{label:'Wed',value:'wed'}]" />
<FormElement type="toggle-group" name="track" label="Track" :options="[{label:'Design',value:'design'},{label:'Dev',value:'dev'},{label:'Product',value:'product'}]" />
<FormElement type="slider" name="volume" label="Volume" :min="0" :max="100" :default-value="40" />
<FormElement type="range" name="budget" label="Budget range" :min="0" :max="1000" :step="50" />
<FormElement type="date" name="arrival" label="Arrival date" />
<FormElement type="tags" name="interests" label="Interests" placeholder="Add interest…" />
<FormElement type="rating" name="excitement" label="Excitement" :max="5" />
<FormElement type="color" name="badge_color" label="Badge color" default-value="#6d28d9" />
<FormElement type="file" name="avatar" label="Avatar" accept="image/*" />
<FormElement type="signature" name="signature" label="Signature" required />
<FormElement type="switch" name="notifications" label="Email me updates" help="You can opt out any time" />
<FormElement type="checkbox" name="terms" label="I accept the terms" required />
<Button type="submit" class="w-full">Submit</Button>
</form>
`,
}),
}

Validation​

import type { Meta, StoryObj } from '@storybook/vue3-vite'
import { useForm } from 'vee-validate'
import * as z from 'zod'
import { FormElement } from '.'
import { Button } from '@/components/ui/button'
const defaultArgs = {
type: 'text',
name: 'field',
label: 'Field label',
}
{
render: () => ({
components: { FormElement, Button },
setup() {
const form = useForm()
const onSubmit = form.handleSubmit(() => {})
return { onSubmit }
},
template: `
<form class="w-96 space-y-5" novalidate @submit="onSubmit">
<FormElement type="text" name="username" label="Username" required :validation="{ minLength: 3, maxLength: 12 }" />
<FormElement type="email" name="email" label="Email" required />
<FormElement type="url" name="website" label="Website" help="Optional, but must be a valid URL when filled" />
<Button type="submit" class="w-full">Validate</Button>
</form>
`,
}),
}