Skip to content
All blocks

[28] Forms

Form With Sections

A long form split into titled sections, each a card of fields with two per row, ending in a bar with the buttons.

1280px

Copy the code

One file with one component and its sample data. It needs @vaneui/ui and its stylesheet, set up as in the installation guide. It passes an onSubmit handler, so in the Next.js App Router add "use client" at the top of its file.

form-sections.tsx

import type { ReactNode } from "react";
import { Button, Card, Col, Container, Field, Grid2, PageTitle, Row, Section, Text, Title } from "@vaneui/ui";
/** One part of the form: its title and a line about it beside a card with the fields */
function FormSection({ title, text, children }: { title: string; text: string; children: ReactNode }) {
return (
<Row tabletStack itemsStart lg>
<Col xs noShrink tabletWFull className="w-64">
<Title sm tag="h2">{title}</Title>
<Text sm secondary>{text}</Text>
</Col>
<Card flex1 wFull className="min-w-0">{children}</Card>
</Row>
);
}
export function FormSections() {
return (
<Section>
<Container itemsStretch>
<Col tag="form" xl className="max-w-4xl" onSubmit={(e) => e.preventDefault()}>
<Col xs>
<PageTitle>New project</PageTitle>
<Text secondary>Set up the project now. You can change everything later in its settings.</Text>
</Col>
<FormSection title="Details" text="A name and a short description, so people know what the project is for.">
<Field type="text" label="Project name" name="name" placeholder="Website relaunch" required />
<Field textarea label="Description" name="description" description="Shown at the top of the project page." />
</FormSection>
<FormSection title="Team" text="Who owns the project and who works on it.">
<Grid2>
<Field select label="Team" name="team" defaultValue="design">
<option value="design">Design</option>
<option value="engineering">Engineering</option>
<option value="marketing">Marketing</option>
</Field>
<Field select label="Lead" name="lead" defaultValue="ana">
<option value="ana">Ana Diaz</option>
<option value="lee">Lee Park</option>
<option value="sam">Sam Ortiz</option>
<option value="mia">Mia Chen</option>
</Field>
</Grid2>
<Field type="email" label="Add people" name="invite" placeholder="name@company.com" description="Separate addresses with commas." />
</FormSection>
<FormSection title="Schedule" text="Dates show on the timeline and in the weekly summary.">
<Grid2>
<Field type="date" label="Start date" name="start" />
<Field type="date" label="Target date" name="target" />
</Grid2>
<Field switch label="Post a summary to the team every Monday" name="summary" defaultChecked />
</FormSection>
<Row justifyBetween borderT paddingY mobileStack itemsStretch>
<Text sm secondary>You can invite more people after the project is created.</Text>
<Row mobileStack>
<Button type="button" secondary mobileWFull>Cancel</Button>
<Button type="submit" filled mobileWFull>Create project</Button>
</Row>
</Row>
</Col>
</Container>
</Section>
);
}

How it adapts

  • 1024px and up: each section title sits in a 256px column beside its card of fields.
  • Below 1024px: the section titles move above their cards.
  • Below 768px: paired fields stack, and the buttons stack and fill the width.

How these props work is in responsive page sections without breakpoint classes.

Adapt it with your coding agent

Add the VaneUI MCP server, and your agent reads the component docs and prop tables while it changes the block: the copy, the sample data or the layout.

$ claude mcp add vaneui -- npx -y @vaneui/mcp

Setup for other editors is in the AI assistants guide.