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

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

Overview

Forms are composed of the input components and a few layout helpers: FormSpacing arranges the fields in a grid, FormDivider structures them and FormRepeat handles lists of entries. This example combines all of them.

Your Personal Information
Name
Date
Your email addresses
Email Addresses
Add one or more email addresses
Your emergency contacts
Contacts
Add contact information
"use client";
import {
Button,
ButtonGroup,
DateInput,
FormDivider,
FormGroup,
FormRepeat,
FormSpacing,
Input,
} from "@brynlabs/fusion-ui";
import React, {useState} from "react";
type EmailAddress = {
email: string;
};
type Contact = {
name: string;
email: string;
};
export const FormExample: React.FC = () => {
const [value, setValue] = React.useState("");
const [date, setDate] = useState<Date>(new Date());
const [emailAddresses, setEmailAddresses] = useState<EmailAddress[]>([]);
const [contacts, setContacts] = useState<Contact[]>([]);
return (
<form>
<FormSpacing>
<FormDivider>Your Personal Information</FormDivider>
<Input
label={"Name"}
value={value}
placeholder={"Your Name"}
onChange={e => {
setValue(e);
}}></Input>
<DateInput
label={"Date"}
type={"datetime"}
timezone={"America/Los_Angeles"}
value={date}
onChange={value => {
setDate(value as Date);
}}></DateInput>
<FormDivider>Your email addresses</FormDivider>
<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>
<FormDivider>Your emergency contacts</FormDivider>
<FormRepeat
label={"Contacts"}
addLabel={"Add Contact"}
hint={"Add contact information"}
value={contacts}
onChange={setContacts}
newItem={() => ({name: "", email: ""})}>
{({value, onChange}) => (
<FormGroup groupLabel={`Contact - ${value.name}`}>
<FormSpacing>
<Input
label={"Name"}
value={value.name}
onChange={change => onChange({...value, name: change})}
placeholder={"John Doe"}
/>
<Input
label={"Email"}
value={value.email}
onChange={change => onChange({...value, email: change})}
placeholder={"john@example.com"}
/>
</FormSpacing>
</FormGroup>
)}
</FormRepeat>
<ButtonGroup>
<Button>Send</Button>
<Button>Delete</Button>
</ButtonGroup>
</FormSpacing>
</form>
);
};