Fieldset example

Related details with native group ownership.

Group contact and delivery fields with native legends, shared hints and one form. Disabled groups stay out of native submission.

Complete React client module · MIT · Next.js and Vite

Interactive example

Related details with native group ownership

Group contact and delivery fields with native legends, shared hints and one form. Disabled groups stay out of native submission.

Keyboard

  • Tab follows editable fields in document order and skips the disabled group.
  • Submit incomplete details, then follow the linked message to the contact field.

States covered

  • Native fieldset and legend
  • Grouped disabled state
  • Required native input
  • Canonical form values

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-fieldset-contact-groups.json
Complete source
React / TypeScript
/*!
MIT License

Copyright (c) 2026 Jaison

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import '@bld8/ui/styles.css';
import {useState} from 'react';
import {Button,Field,Fieldset,FormErrorSummary,Input} from '@bld8/ui';
export default function GroupedContactExample(){
  const [result,setResult]=useState('No contact read yet.'),[errors,setErrors]=useState<Record<string,string>>({});
  return <form noValidate aria-label="Grouped contact example" onSubmit={event=>{event.preventDefault();const data=new FormData(event.currentTarget);if(!String(data.get('contact')??'').trim()){setErrors({contact:'Enter a contact name.'});return;}setErrors({});setResult(String(data.get('contact'))+' | '+String(data.get('team'))+' | disabled: '+String(data.has('retired')));}} style={{display:'grid',gap:24,maxWidth:600}}>
    <FormErrorSummary errors={errors} fieldLabels={{contact:'Contact name'}}/>
    <Fieldset legend="Contact details" hint="These fields describe who will receive the review."><Field label="Contact name" required><Input name="contact" autoComplete="name" onChange={()=>setErrors({})}/></Field><Field label="Team"><Input name="team" defaultValue="Interface team"/></Field></Fieldset>
    <Fieldset legend="Retired destination" hint="Disabled groups are excluded from submission." disabled><Field label="Retired contact"><Input name="retired" defaultValue="Old team"/></Field></Fieldset>
    <Button type="submit">Read grouped contact</Button><p role="status">{result}</p>
  </form>;
}