shadcn.io is not affiliated with official shadcn/ui
User Fields Settings Block for React
A profile fields panel: a table with a row per field showing its type, a Required switch, who can see it and its rule in words, with rules that open in place (a preset, the shortest and longest answer and a Try a value field that says Valid or why not) and the member's form drawn from the same fields.
Installation
Overview
Let admins shape the profile every member fills in, and test the rule before anyone meets it, with this user fields panel for React with Base UI. A hairline frame with a plus mark on each corner holds a native table with a row for each of five fields: its name with a type Badge, a Switch for Required, a Native Select for who can see it (Everyone, Managers, HR only) and its rule in words, such as "Text, 2 to 60 characters". A Rules Button opens that row's rules in place: a Segment Group of presets (None, Email, URL, Digits only), the shortest and longest answer, and Try a value, an Input that answers at once with Valid or the reason, like "Too short: 2 more characters." One row's rules are always open, so opening another closes the first and the table keeps its height. Under the table the member's form is drawn from the same fields, with a star on the required ones and who sees each. The action foot counts unsaved changes beside a Shine Button to save and an outline Button to discard. On a phone every field is a card. It's built from Badge, Switch, Native Select, Segment Group, Input, Button, Shine Button and Guides, with a CSS entrance only. For a directory, an HR tool, a CRM or any product whose members have a profile.
FAQ
How does Try a value decide?
A pure function, checkValue, takes the field's saved-so-far rule and what you typed. It checks an empty value first (Required or Empty is fine), then the preset (an email needs an @ and a domain, a URL starts with https://, digits are digits), then the length, and returns the first reason it fails or Valid. The Start date field reads a year-month-day value and refuses a day after the fixed as-of day. The same function should run on your server when a member saves, since a check in the browser is a courtesy.
Why is one row always open?
So the table never changes height: opening another row closes the first, and every row's rules take the same space. It follows the accordion pattern that doesn't allow collapsing, so the open row's Rules button is marked disabled but stays in the tab order, and pressing it says the rules stay open in the status line. Each button is named for its field ("Rules for Phone") and tells a screen reader whether it is expanded.
What is the form at the bottom?
A drawing of what a new member fills in, made from the same list: each label, a star when the field is required or "(optional)" when it isn't, a drawn box with the glyph of its type, and a line saying who sees the answer. It changes as you flip a switch or pick an audience, before anything is saved. The boxes are decorative; the labels and the audience lines are text.
What stays local, and how do I wire it up?
Everything. Save keeps the edited fields as the saved ones, in this page only, and says how many changes it kept; Discard puts the saved ones back. To make it real, send each field's id, whether it is required, who can see it, its preset and its two lengths to your API in the save handler, and enforce the same rules there. Save and Discard stay in place and focusable while nothing changed and answer "No changes to save." in words. The rules and the tester live in SAVED and checkValue.
Is the table accessible, and how does it look on a phone?
It is a native table with a caption, column headers, and the field as each row's header; each switch and menu is named for its field ("Required: Job title"). The spoken verdict on a typed value comes once typing pauses, in the one polite status line, never on load. Below the medium breakpoint each row becomes a card with the same controls, each labelled, and the rules open under their card; the save bar stays pinned to the bottom of the screen.
Related
- Pro
Custom Fields Settings
Fields and formsAn Add field sheet open over a drawn Contacts table: a name, a type picked from six cards, the options that belong to that type, a live preview of the field, and an Add that appends a column to the table behind it.
- Pro
Registration Fields Settings
Fields and formsA sign-up form editor where the form is the editor: a drawn sign-up page with six fields, each with a Required toggle, a Show switch and Move up and Move down, a locked email and password, and a Publish form button in a slim bar.
- Pro
Default Values Settings
Fields and formsA task defaults panel: a priority, an assignee, days until due (calendar or working days), an estimate, up to four labels and who can see a task, beside a drawn new task that shows every default applied and the due date worked out from a fixed day.
- Pro
Profile Settings
Privacy and consentA profile visibility page: five parts of a profile, each with a menu for who sees it (Everyone, Workspace, Only me), beside a drawn profile card with a Preview as choice (Public, Teammate, Me) that hides what that viewer cannot see.
- Pro
Team Members Settings
Team and rolesA members panel with seat and two-factor meters, a native table with row selection, a role menu per person and, pinned at the foot, a bulk role change and Remove that an Undo walks back one step at a time.
- Pro
Role Permissions Settings
Team and rolesA roles window with a rail of five roles and a detail of grouped permissions: mixed-state group boxes, a Compare with select that marks each permission with a plus or a minus, read-only system roles and Duplicate to edit.