Skip to main content

FormDrawer

A drawer panel that combines form state, mutation execution, and submit/reset actions. Same API as FormModal but rendered as a side drawer.

VEF-specific component. Moved from @vef-framework-react/starter to @vef-framework-react/components in v2.1.6.

When to Use

  • Create and edit forms that open in a side drawer.
  • Forms that benefit from more vertical space than a modal provides.

Form content taller than the drawer scrolls inside the drawer body; the body's bottom padding is kept after the last field, so scrolled to the end the content never sits flush against the footer actions.

Basic Usage

import { FormDrawer } from '@vef-framework-react/components';

interface UserForm {
name: string;
email: string;
}

export default function EditUserDrawer({ open, onClose }) {
return (
<FormDrawer<UserForm>
open={open}
title="Edit User"
width={480}
mutationFn={updateUser}
mutationMeta={{ invalidates: [[findUserPage.key]] }}
afterSubmit={() => onClose()}
onClose={onClose}
>
{(form) => (
<>
<form.AppField name="name">
{(field) => <field.Input label="Name" required />}
</form.AppField>
<form.AppField name="email">
{(field) => <field.Input label="Email" required />}
</form.AppField>
</>
)}
</FormDrawer>
);
}

API

PropTypeDefaultDescription
openbooleanfalseWhether the drawer is visible
titleReactNodeDrawer title
widthstring | numberDrawer width
placementDrawerProps['placement']Drawer placement
resizablebooleanWhether the drawer is resizable
defaultValuesTValuesInitial form values
disabledbooleanfalseDisable the form
formComponentElementType"form"Element type for the inner form wrapper
formLayoutFormLayoutLayout of the form items inside the drawer — layout ('horizontal' | 'vertical'), labelAlign and labelWidth. Defaults to the horizontal, right-aligned label layout (see Form)
mutationFnMutationFunction<ApiResult<TData>, TValues>Mutation to execute on submit
mutationMetaMutationMetaMutation metadata
beforeSubmit(values) => Awaitable<TValues>Transform values before submission
afterSubmit(values, data) => Awaitable<void>Called after successful submission
onSubmit(values) => Awaitable<void>Custom submit handler
onReset(defaultValues?) => voidCalled on form reset
onClose() => voidCalled when drawer closes
renderActions(formApi, defaults: { submitButton, resetButton }) => ReactNodeCustom footer actions; defaults carries the default submit/reset buttons to reuse alongside custom ones
submitButtonPropsExcept<SubmitButtonProps, 'onSubmit' | 'disabled' | 'loading'>Submit button customization (only used when renderActions is not provided)
resetButtonPropsExcept<ResetButtonProps, 'onReset' | 'disabled' | 'loading'> | falseReset button customization; false to hide (only used when renderActions is not provided)
childrenReactNode | (formApi) => ReactNodeForm content