Fusion UI LogoFusion UI Logo
Fusion UI LogoFusion UI Logo
/
Getting Started
Concepts
Components
Example Apps
Getting Started
Concepts
Components
Example Apps
Fusion UI LogoFusion UI Logo
Getting Started
Concepts
Components
Example Apps
Overview
Actions
Button
Button Group
Segmented Button
Deprecated
Split Button
Toggle Button
Click To Copy
Toolbar
Navigation
Main Nav
Side Menu
Page Header
Tabs
Breadcrumbs
On-Page Menu
Link
Command Menu
Application Switcher
Context Switcher
Account Menu
Menu Bar
Deprecated
Inputs & Forms
Form
Form Actions
Deprecated
Form Divider
Form Field
Form Repeat
Form Spacing
Input
Prefix & Suffix
Rich Text Input
Autocomplete
Select
Date / Time Input
Calendar
Slider
Selection
Checkbox
Radio
Switch
Switch Select
Chip
Chip Choice
Chip Filter
Chip Input
Chip Sortable
Visual Select
Pricing Plan Select
Feedback & Loading
Banner
Inline Message
Snackbar
Inline Snackbar
Loading Spinner
Skeleton
Text Skeleton
Contextual Information
Badge
Status
Tag
Tooltip
Info
Hotkey
Icon
Icon Sizer
Containers & Overlays
Tile
Tile Content
Tile Footer
Tile Header
Annotated Section
Modal
Sheet
Popover
Context Menu
Data Display
Data Table
List
Timeline
Data Visualization
KPI Card
Ratio Card
Bar Chart
Line Chart
Pie Chart
Heatmap Calendar
Layout
Container
Stack Layout
Flow Layout
Internals
Blanket
Expansion Panel
Menu List Base
Menu Group
Search Bar
Components
...
Form
Form Repeat

Form Repeat

Lays out fields, groups, repeated entries and the actions of a form.

Overview

FormRepeat lets people add, remove and reorder entries of the same shape, e.g. several email addresses. Every item needs a unique id for tracking and drag and drop.

Email Addresses
Add one or more email addresses
"use client";
import {FormRepeat, Input} from "@brynlabs/fusion-ui";
import React, {useState} from "react";
type EmailAddress = {
email: string;
};
export const SimpleExample = () => {
const [emailAddresses, setEmailAddresses] = useState<EmailAddress[]>([]);
return <FormRepeat
label={"Email Addresses"}
addLabel={"Add Email"}
hint={"Add one or more email addresses"}
value={emailAddresses}
onChange={setEmailAddresses}
newItem={() => ({email: ""})}>
{({value, onChange}) => (
<Input
value={value.email}
onChange={change => onChange({...value, email: change})}
placeholder={"email@example.com"}
/>
)}
</FormRepeat>;
};

Multiple fields with FormGroup

Use FormGroup for several fields per entry.

Expansion mode:

Multiple
Contacts
Add contact information
"use client";
import {Checkbox, FormGroup, FormRepeat, FormSpacing, Input, Select} from "@brynlabs/fusion-ui";
import React, {useState} from "react";
type Contact = {
name: string;
email: string;
};
type ExpansionMode = "single" | "multiple";
export const FormGroupExample = () => {
const [contacts, setContacts] = useState<Contact[]>([]);
const [expansionMode, setExpansionMode] = useState<ExpansionMode>("multiple");
const [autoExpand, setAutoExpand] = useState(false);
return (
<FormSpacing>
<div style={{display: "flex", alignItems: "center", gap: "0.5rem", marginTop: "2rem"}}>
<p>Expansion mode:</p>
<Select<ExpansionMode>
placeholder="Select expansion mode"
value={expansionMode}
values={["single", "multiple"]}
mapValueToString={value => (value === "single" ? "Single" : "Multiple")}
onChange={value => {
if (value !== null) {
setExpansionMode(value);
}
}}
/>
</div>
<Checkbox
label="Automatically expand new contacts"
value={autoExpand}
onChange={setAutoExpand}
/>
<FormRepeat
label="Contacts"
addLabel="Add Contact"
hint="Add contact information"
value={contacts}
onChange={setContacts}
newItem={() => ({name: "", email: ""})}
expansionMode={expansionMode}
autoExpand={autoExpand}>
{({value, onChange}) => (
<FormGroup
groupLabel={value.name ? `Contact – ${value.name}` : "New Contact"}>
<FormSpacing>
<Input
label="Name"
value={value.name}
onChange={name => onChange({...value, name})}
placeholder="John Doe"
/>
<Input
label="Email"
value={value.email}
onChange={email => onChange({...value, email})}
placeholder="john@example.com"
/>
</FormSpacing>
</FormGroup>
)}
</FormRepeat>
</FormSpacing>
);
};

Custom button positions

FormRepeatChild places the reorder and delete buttons within your own layout.

Team Members
"use client";
import {Checkbox, FormRepeat, FormRepeatChild, Input} from "@brynlabs/fusion-ui";
import React, {useState} from "react";
type TeamMember = {
name: string;
email: string;
};
export const FormRepeatChildExample = () => {
const [teamMembers, setTeamMembers] = useState<TeamMember[]>([]);
return (
<FormRepeat
label={"Team Members"}
addLabel={"Add Team Member"}
value={teamMembers}
onChange={setTeamMembers}
newItem={() => ({name: "", email: ""})}>
{({value, onChange}) => (
<FormRepeatChild>
{({reorderButton, deleteButton, isExpanded, onExpandedChange}) => (
<div style={{padding: "1rem", background: "gray"}}>
{reorderButton}
<Checkbox value={isExpanded} onChange={onExpandedChange} label={"Expanded"}></Checkbox>
{isExpanded && (
<Input
label={"Name"}
value={value.name}
onChange={change => onChange({...value, name: change})}
placeholder={"Jane Smith"}
/>
)}
{deleteButton}
</div>
)}
</FormRepeatChild>
)}
</FormRepeat>
);
};
On this page
  • Overview
  • Multiple fields with FormGroup
  • Custom button positions