VfTabs
Basic
VfTabs renders the tab bar in a tabbed form. Override the tabs slot on VfForm to render VfTabs with custom props or alongside additional content.
vue
<VfForm tabbed>
<template #tabs="{ pager }">
<VfTabs :pager="pager" />
</template>
<VfGroup name="general" page="General">
<VfText name="name" label="Name" />
</VfGroup>
<VfGroup name="profile" page="Profile">
<VfText name="bio" label="Bio" />
</VfGroup>
</VfForm>vue
<template>
<VfForm tabbed>
<template #tabs="{ pager }">
<VfTabs :pager="pager" />
</template>
<VfGroup name="general" page="General">
<VfText name="name" label="Name" />
</VfGroup>
<VfGroup name="profile" page="Profile">
<VfText name="bio" label="Bio" />
</VfGroup>
</VfForm>
</template>vue
<script setup lang="ts">
import { defineSchema, defineSlot, useForm } from '@vueform/ui'
import { h, resolveComponent } from 'vue'
const schema = defineSchema({
general: {
type: 'group',
page: 'General',
schema: {
name: { type: 'text', label: 'Name' },
},
},
profile: {
type: 'group',
page: 'Profile',
schema: {
bio: { type: 'text', label: 'Bio' },
},
},
})
const [MyForm] = useForm({
schema,
tabbed: true,
slots: {
tabs: defineSlot('VfForm.tabs', {
props: ['pager'],
setup: (props) => () => {
const VfTabs = resolveComponent('VfTabs')
return h(VfTabs, { pager: props.pager })
},
}),
},
})
</script>
<template>
<MyForm />
</template>Props
Configure the component's behavior and appearance with these props.
Component
| Prop | Default | Description |
|---|---|---|
pager | — | Required. The pager instance managing tab navigation. |
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. |
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. |
wrapper | index label meta selected invalid loading el$ page | Slot that replaces each tab wrapper element. Receives tab state and page info. |
default | index label meta selected invalid loading el$ bindings | Slot that replaces each tab's inner content. Receives tab state. |
Parts
DOM attribute overrides targeting internal elements. See Parts for details.
Example
root
The root tabs container element.
| Element | <div> |
| Classes | .vf-tabs |
list
The tab list element.
| Element | <ul> |
| Classes | .vf-tabs-wrapper |
wrapper
Each tab wrapper. Receives the resolved page data.
| Element | <li> |
| Classes | .vf-tab-wrapper |
| Bindings | data-selected data-invalid |
tab
The tab button element.
| Element | <button> |
| Classes | .vf-tab |
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-tab-padding: 0 1rem 0.5rem 1rem;
--vf-tabs-gutter-x: 0;
--vf-tabs-gutter-y: 0;
--vf-tabs-margin: 0 0 var(--vf-gutter) 0;
--vf-tab-color: inherit;
--vf-tab-color-danger: var(--vf-red);
--vf-tab-color-selected: inherit;
--vf-tab-color-selected-danger: var(--vf-red);
--vf-tab-bg: transparent;
--vf-tab-bg-danger: transparent;
--vf-tab-bg-selected: transparent;
--vf-tab-bg-selected-danger: transparent;
--vf-tab-border-color: transparent;
--vf-tab-border-color-danger: transparent;
--vf-tab-border-color-selected: var(--vf-brand);
--vf-tab-border-color-selected-danger: var(--vf-red);
--vf-tab-border-width: 0 0 2px 0;
--vf-tab-radius: 0px;
--vf-tabs-font-size: 1rem;
}ts
{
/**
* Component tokens
* -------------------------------------------------------------------------- */
tabPadding: '0 1rem 0.5rem 1rem',
tabsGutterX: '0',
tabsGutterY: '0',
tabsMargin: '0 0 $gutter 0',
tabColor: 'inherit',
tabColorDanger: '$red',
tabColorSelected: 'inherit',
tabColorSelectedDanger: '$red',
tabBg: 'transparent',
tabBgDanger: 'transparent',
tabBgSelected: 'transparent',
tabBgSelectedDanger: 'transparent',
tabBorderColor: 'transparent',
tabBorderColorDanger: 'transparent',
tabBorderColorSelected: '$brand',
tabBorderColorSelectedDanger: '$red',
tabBorderWidth: '0 0 2px 0',
tabRadius: '0px',
tabsFontSize: '1rem',
}