Reads rows in the tables you allow.
Adds rows. Changes data.
Posts to attached channels.
A form that locks its fields while saving, moves focus to the first error, and ends with a save area that explains why it cannot save yet.
pnpm dlx shadcn@latest add https://sprout.tulipfarm.ai/r/form.jsonCopies Form and the components it uses (Alert, Badge, Button, and Field) into your app, installs the packages, and adds the styles. Then import it from @/components/ui/form. Needs Tailwind CSS 4 and a components.json from shadcn init.
Install the following dependencies:
pnpm add clsx tailwind-mergeAdd Sprout base once per app: the cn() helper and the design tokens.
lib/sprout/classes.tsAdd the components it uses: Alert, Badge, Button, and Field.
Copy and paste the following code into your project.
'use client';
import { useEffect, useRef, useState, type ReactElement, type ReactNode } from 'react';
import { cn } from '@/lib/sprout/classes';
import { Alert } from '@/components/ui/alert';
import { Badge } from '@/components/ui/badge';
import {
Button,
jumpTo,
useActionControl,
type ButtonBlockerFix as ActionBlockerFix,
type ButtonState as ActionControlState,
} from '@/components/ui/button';
import { FieldsDisabled } from '@/components/ui/field';
export const formFooterLayoutNames = ['bar', 'stack', 'compact'] as const;
export const formSectionLevelNames = [2, 3] as const;
export type FormFooterLayout = (typeof formFooterLayoutNames)[number];
export type FormSectionLevel = (typeof formSectionLevelNames)[number];
export type FormBlockerFix = ActionBlockerFix;
export type FormActionState = ActionControlState;
export interface FormProps {
id?: string | undefined;
disabled?: boolean | undefined;
onSubmit: () => 'invalid' | void;
label?: string | undefined;
className?: string | undefined;
children: ReactNode;
}
export function Form({ id, disabled = false, onSubmit, label, className, children }: FormProps) {
const formRef = useRef<HTMLFormElement>(null);
const [failedSubmits, setFailedSubmits] = useState(0);
useEffect(() => {
const invalid = failedSubmits > 0 ? formRef.current?.querySelector('[aria-invalid="true"]') : null;
if (invalid) jumpTo(invalid);
}, [failedSubmits]);
return (
<FieldsDisabled value={disabled}>
<form
id={id}
ref={formRef}
data-slot="form"
noValidate
aria-label={label}
className={cn('sprout-form', className)}
onSubmit={event => {
event.preventDefault();
if (onSubmit() === 'invalid') setFailedSubmits(count => count + 1);
}}
>
{children}
</form>
</FieldsDisabled>
);
}
export interface FormSectionProps {
title: string;
description?: string | undefined;
meta?: string | undefined;
label?: string | undefined;
id?: string | undefined;
level?: FormSectionLevel | undefined;
className?: string | undefined;
children: ReactNode;
}
export function FormSection({ title, description, meta, label, id, level = 2, className, children }: FormSectionProps) {
const Heading = level === 3 ? 'h3' : 'h2';
return (
<section
id={id}
data-slot="form-section"
aria-label={label ?? title}
className={cn('sprout-form-section', className)}
>
<div className="sprout-form-section-header">
<div className="sprout-form-section-text">
<Heading className="sprout-form-section-title">{title}</Heading>
{description && <p className="sprout-form-section-description">{description}</p>}
</div>
{meta && <Badge variant="secondary">{meta}</Badge>}
</div>
<div className="sprout-form-section-content">{children}</div>
</section>
);
}
export type FormCancel =
| { kind: 'reset'; label: string; onReset: () => void }
| { kind: 'leave'; label: string; link: ReactElement };
export interface FormFooterSubmit {
label: string;
pendingLabel: string;
state: FormActionState;
}
export interface FormFooterSecondarySubmit {
label: string;
disabled: boolean;
onSelect: () => void;
}
export interface FormFooterProps {
form?: string | undefined;
summary?: ReactNode;
submit: FormFooterSubmit;
secondarySubmit?: FormFooterSecondarySubmit | undefined;
dirty: boolean;
cancel?: FormCancel | undefined;
note?: string | undefined;
error?: string | undefined;
layout?: FormFooterLayout | undefined;
className?: string | undefined;
children?: ReactNode;
}
export function FormFooter({
form,
summary,
submit,
secondarySubmit,
dirty,
cancel,
note,
error,
layout = 'bar',
className,
children,
}: FormFooterProps) {
const action = useActionControl(submit.state);
const stack = layout === 'stack';
const compact = layout === 'compact';
const size = stack ? 'lg' : 'md';
const wide = stack ? 'sprout-form-footer-wide' : undefined;
const save = (
<Button type="submit" form={form} size={size} className={wide} {...action.button}>
{submit.state.kind === 'busy' ? submit.pendingLabel : submit.label}
</Button>
);
const secondary = secondarySubmit && (
<Button
type="submit"
form={form}
size={size}
variant="outline"
className={wide}
disabled={secondarySubmit.disabled}
onClick={secondarySubmit.onSelect}
>
{secondarySubmit.label}
</Button>
);
const cancelButton = !cancel ? null : cancel.kind === 'leave' ? (
<Button variant="outline" size={size} className={wide} nativeButton={false} render={cancel.link}>
{cancel.label}
</Button>
) : dirty && submit.state.kind !== 'busy' ? (
<Button variant="outline" size={size} className={wide} onClick={cancel.onReset}>
{cancel.label}
</Button>
) : null;
const status = (
<>
{dirty && (
<p className="sprout-form-footer-dirty">
<span aria-hidden="true" className="sprout-form-footer-dirty-dot" />
Unsaved changes
</p>
)}
{note && <p className="sprout-form-footer-note">{note}</p>}
</>
);
return (
<div data-slot="form-footer" data-layout={layout} className={cn('sprout-form-footer', className)}>
{stack ? (
<>
{status}
<div className="sprout-form-footer-stack">
{save}
{secondary}
{cancelButton}
</div>
</>
) : (
<div className="sprout-form-footer-row">
<div className={compact && !summary ? 'sprout-form-footer-sr-only' : 'sprout-form-footer-status'}>
{summary ?? status}
</div>
<div className="sprout-form-footer-actions">
{compact && children}
{cancelButton}
{secondary}
{save}
</div>
</div>
)}
{action.reason}
{error && <Alert variant="destructive">{error}</Alert>}
{!compact && children}
</div>
);
}Add the styles to your global CSS, after @import "tailwindcss".
Import it from @/components/ui/form. Update the paths if your @/ alias points elsewhere.
pnpm add @tulipfarm/sprout@import "tailwindcss";
@import "@tulipfarm/sprout/styles.css";The package keeps the source and ships fixes with each release. Import from @tulipfarm/sprout/form.
import { Form, FormFooter, FormSection } from "@tulipfarm/sprout/form";
import { Field } from "@tulipfarm/sprout/field";
import { Input } from "@tulipfarm/sprout/input";
<Form label="Change interval" disabled={saving} onSubmit={() => {
if (error) { setChecked(true); return "invalid"; }
save(minutes);
}}>
<FormSection title="Scheduled trigger" description="Start this agent on an interval.">
<Field label="Run every" required error={checked ? error : undefined}>
<Input type="number" value={minutes} onChange={…} />
</Field>
</FormSection>
<FormFooter
dirty={minutes !== saved}
note="Saving makes you the sponsor."
submit={{
label: "Save interval",
pendingLabel: "Saving interval…",
state: saving ? { kind: "busy" } : { kind: "ready" },
}}
cancel={{ kind: "reset", label: "Discard changes", onReset: reset }}
/>
</Form>Form renders a noValidate form and prevents the browser submit. Return "invalid" from onSubmitafter you show errors; the form then scrolls to and focuses the first control with aria-invalid="true". disabledlocks every Field, ChoiceGroup, andCheckboxField inside. label names the form.
FormSection is a bordered region named by itstitle, or by label when set. It takes an optionaldescription, a meta badge such as3 / 20, an id to jump to, andlevel2 or 3 for the heading.
Clear a field and save. Focus moves to the first error, the footer shows a summary, and Discard changes restores the saved values. While saving, the fields lock and Discard changes hides.
bar sits under a divider for page and section forms.stack uses full-width large buttons for sign-in, onboarding, and dialogs. compact fits chat cards: it hides the status line from sight, and its children sit beside the buttons instead of below them.
How long should my replies be?
submit={{
label: "Add Slack destination",
pendingLabel: "Adding Slack destination…",
state: team ? { kind: "ready" } : {
kind: "blocked",
reason: "Choose a destination team below first.",
fix: { kind: "jump", label: "Choose a team", target: "slack-destination-team" },
},
}}busy shows pendingLabel and setsaria-busy. blocked shows itsreason under the buttons and links it witharia-describedby. Busy and blocked buttons stay focusable so keyboard users hear why. A fix adds a link button:jump focuses an element by id, action runs a callback, and link renders your router link.dirty shows Unsaved changes; a reset cancel shows only while dirty and not busy.
Connect a personal account, or ask a team integration manager for integration use and repository read permissions.
Meta badges count choices or items. The header wraps the badge under the title when the section is narrow. Long titles and descriptions wrap.
Choose actions by app. Skills guide the work; these choices grant the capability.
Give each recurring run its own task. Schedules stay off until activation.
Runs use the version you activate. Activate again after you change the instructions.
Read rows, Post to Slack
Where this agent is listed and who can use or manage it.
Teams that can use this agent. Managers can also edit it.
Operations · can use
Removes the agent and stops its active versions.
secondarySubmit adds an outline submit such as Save draft; itsonSelect runs before the form submits. Aleave cancel renders a link. Pass form to put the footer outside its form, and summary to replace the status line with your own content. Footer children carry save feedback, alerts, and extra actions.
Where this agent is listed and who can use or manage it.
Teams whose permissions this agent uses when it runs.
Which supplier should I contact first?
Name every form with label or a surrounding section. Errors render in a destructive Alert. Status lines fade in over 180ms and appear at once with reduced motion. Saving, routing, and data in these examples are sample code; the textarea is a docs-only stand-in.