VfAddon
Basic
VfAddon renders a single addon cell inside an element's input wrapper. It is used when overriding the addonBefore or addonAfter slot of an element to provide custom addon content.
vue
<VfText name="website" label="Website">
<template #addon-before>
<VfAddon>https://</VfAddon>
</template>
</VfText>vue
<template>
<VfText name="website" label="Website">
<template #addon-before>
<VfAddon>https://</VfAddon>
</template>
</VfText>
</template>vue
<script setup lang="ts">
import { defineSchema, defineSlot, useForm } from '@vueform/ui'
import { h, resolveComponent } from 'vue'
const schema = defineSchema({
website: {
type: 'text',
label: 'Website',
slots: {
'addon-before': defineSlot('VfText.addon-before', {
setup: () => () => {
const VfAddon = resolveComponent('VfAddon')
return h(VfAddon, null, () => 'https://')
},
}),
},
},
})
const [Form] = useForm({ schema })
</script>
<template>
<Form />
</template>Props
Configure the component's behavior and appearance with these props.
Component
| Prop | Default | Description |
|---|---|---|
addon | — | The addon content — a text value or an element schema tuple. |
Customization
| Prop | Default | Description |
|---|---|---|
parts | — | Custom DOM attribute overrides for the component's structural parts. |
class | — | CSS classes to apply to the component's root element. |
classes | — | Custom CSS class overrides for the component's structural parts. |
reclass | — | CSS class overrides that replace (rather than merge with) default classes. |
slots | — | Custom Vue components to use for named slots. Every component resolves it through the standard outlets pipeline (see useOutlets). |
presets | — | Named configuration presets to apply to the component. |
template | — | A custom Vue component to use as the template instead of the default. |
component | — | A custom Vue component to render in the component's default slot. |
Context
Reactive properties and methods accessible on the component's Context object.
General
| Name | Description |
|---|---|
props | The resolved component props with defaults applied. |
Addon
| Name | Description |
|---|---|
resolved | Resolves the addon prop into a sanitized text string or a dynamic component descriptor ({ component, props }) for rendering. |
Layout
| Name | Description |
|---|---|
classes | The resolved CSS class map for the component. |
parts | The resolved DOM attribute overrides for internal elements. |
Events
| Name | Description |
|---|---|
fire() | Fires an event synchronously, invoking before, main, and after listeners in order. |
fireAsync() | Fires an event asynchronously, awaiting each callback and short-circuiting when any returns false. |
on() | Subscribes a callback to a specific event. |
off() | Removes a previously registered event callback. |
onBefore() | Registers a callback that runs before the main event listeners. |
onAfter() | Registers a callback that runs after the main event listeners. |
Events
Events emitted by the component. See Events for details.
| Name | Params | Description |
|---|---|---|
beforeMount | context$ | Emitted before the component is mounted. |
mounted | context$ | Emitted after the component is mounted. |
beforeUnmount | context$ | Emitted before the component is unmounted. |
unmounted | context$ | Emitted after the component is unmounted. |
updated | context$ | Emitted after the component is updated. |
Slots
Named Slots for replacing parts of the component's rendering.
| Name | Scope | Description |
|---|---|---|
template | context | Slot that replaces the entire component rendering. Receives the full component context as a single context prop. |
default | — | Default slot for addon content. |
Parts
DOM attribute overrides targeting internal elements. See Parts for details.
Example
root
The root wrapper element.
| Element | <div> |
| Classes | .vf-addon |
Tokens
All the CSS variables that control this component's appearance with default values in the default theme. See Themes & Tokens for details.
css
:root {
/**
* Component tokens
* -------------------------------------------------------------------------- */
--vf-addon-bg: var(--vf-white);
--vf-addon-bg-danger: var(--vf-white);
--vf-addon-color: inherit;
--vf-addon-color-danger: inherit;
--vf-addon-border-color: var(--vf-gray-300);
--vf-addon-border-color-danger: var(--vf-gray-300);
--vf-addon-border-style: solid;
--vf-addon-border-width: 1px;
--vf-addon-radius: calc(var(--vf-radius) - var(--vf-border-width-t));
--vf-addon-after-padding: 0 var(--vf-px);
--vf-addon-before-margin: 0;
--vf-addon-before-padding: 0 var(--vf-px);
}ts
{
/**
* Component tokens
* -------------------------------------------------------------------------- */
addonBg: '$white',
addonBgDanger: '$white',
addonColor: 'inherit',
addonColorDanger: 'inherit',
addonBorderColor: '$gray300',
addonBorderColorDanger: '$gray300',
addonBorderStyle: 'solid',
addonBorderWidth: '1px',
addonRadius: 'calc($radius - $borderWidthT)',
addonAfterPadding: '0 $px',
addonBeforeMargin: '0',
addonBeforePadding: '0 $px',
}