Skip to content

Conversation

@mj12albert
Copy link
Member

@mj12albert mj12albert commented Oct 16, 2025

Preview: https://deploy-preview-2989--base-ui.netlify.app/react/handbook/forms

Added a doc on how to build forms with plain Base UI and guides for React Hook Form and TanStack Form.

Also on the pages of each labelable control, added a bullet point about accessible name and linked to the new doc, it seems more space-efficient than repeating a whole snippet or demo (e.g. like Headless UI or RA).

Only added Tailwind demos, was thinking to not have CSS modules since styling is not the focus of the doc and the styling is already obscured a bit in the demos already.

Closes #21

@mj12albert mj12albert added the docs Improvements or additions to the documentation. label Oct 16, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 16, 2025

vite-css-base-ui-example

pnpm add https://pkg.pr.new/mui/base-ui/@base-ui-components/react@2989
pnpm add https://pkg.pr.new/mui/base-ui/@base-ui-components/utils@2989

commit: 779e58f

@netlify
Copy link

netlify bot commented Oct 16, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 779e58f
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6914b6500fba230009c1666b
😎 Deploy Preview https://deploy-preview-2989--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@mui-bot
Copy link

mui-bot commented Oct 16, 2025

Bundle size report

Bundle Parsed size Gzip size
@base-ui-components/react 0B(0.00%) 0B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@mj12albert mj12albert force-pushed the docs/forms-guide branch 6 times, most recently from a1de574 to 8d56a2e Compare October 18, 2025 14:28
@mj12albert mj12albert marked this pull request as ready for review October 18, 2025 14:49
@mj12albert

This comment was marked as resolved.

@atomiks
Copy link
Contributor

atomiks commented Oct 21, 2025

  • The Toast styles should match the toast hero demo styles (e.g. swiping is selecting text in this one); also use limit={1} on the provider given it's tall. You can use [data-swipe-ignore] on parts of text that should be selectable
  • RHF doesn't use the re-export pattern that's used in the plain Base UI demo, but should?
  • Combobox checkmark styles look off compared to the hero demo styles
  • Group *-pattern imports together at the top as it looks cleaner than scattering them with the non-star pattern imports
  • The input focus visible styles should match Field hero demo
  • The CodeSandbox link in the top-right should have equal padding from the x/y axis, when hovering it it has less x-axis than y-axis padding from the edges of its container
  • Use labeling not labelling as we're following standard US/programming style English


## TanStack Form

[TanStack Form](https://tanstack.com/form/v1/docs/overview) is a form library with a function-based API for orchestrating validations that can also be integrated with Base UI.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT about linking to the latest doc?
Or do we want to ensure the stability of the example if following majors bring significant BCs?

Suggested change
[TanStack Form](https://tanstack.com/form/v1/docs/overview) is a form library with a function-based API for orchestrating validations that can also be integrated with Base UI.
[TanStack Form](https://tanstack.com/form/latest/docs/overview) is a form library with a function-based API for orchestrating validations that can also be integrated with Base UI.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think v1 is good for now... I'm sure v2 will have some big changes


Base UI also supports [TanStack Form](https://tanstack.com/form/v1/docs/overview), which uses a function-based API to orchestrate validations.

import { DemoTanstackForm } from './demos/tanstack-form';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, gotcha. 👍
Then, it's only the section headings left, and even those could be left for a follow-up if they need unrelated internal changes. 👌

@sss-Mihail-sss
Copy link

Can you add an example of react-hook-form + zod?


import { DemoBaseUIForm } from './demos/hero';

<DemoBaseUIForm showExtraPlaygroundLink />
Copy link
Contributor

@atomiks atomiks Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Select trigger's and radio group's outline is 1px, not 2px like the other controls

Comment on lines +5 to +6
export function Root({ className, ...props }: Checkbox.Root.Props) {
return (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The checkbox example used (Backup schedule) seems like a radio group not a checkbox group. Maybe another example can be used to demonstrate checkboxes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated it to this:
Screenshot 2025-11-12 at 11 56 48 PM

It's quite common to have all daily/weekly/monthly backups but maybe it's not obvious... wasn't easy to find sth else from the AWS UI that can be easily oversimplified into a checkbox group (rows upon rows of ungrouped checkboxes are everywhere tho)

Comment on lines 48 to 51
if (text === 'React Hook Form' || text === 'TanStack Form') {
node.properties.id = `${stringToUrl(text)}-${stringToUrl(toString(node))}`;
break;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you considered going for a similar approach to Material docs, where a repeated hash is prepended with -N as in #initialize-the-form and #initialize-the-form-2 in the TanStack Forms case?

The other alternative (my biggest preference) would be to join hashes of nested headings.
Yes, that would break currently existing links in the wild, but I wager that the price to pay is not that high compared to piece of mind we'd get. 🙈 🤷

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other alternative (my biggest preference) would be to join hashes of nested headings

Yeah I think this is better than adding -N as it's more readable, but maybe it's enough to do it selectively like with this file? The other common h2s (Examples, API reference) are much more unlikely to have duplicate heading text

that would break currently existing links in the wild

We'd just have to maintain redirects like this for a very long time 😅 https://github.com/mui/material-ui/blob/master/docs/public/_redirects

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, no objections to going with the simple solution. 👍
We can consider abstracting it if we need to tweak this place the 3rd or 4th time. 👌

@mj12albert
Copy link
Member Author

Can you add an example of react-hook-form + zod?

Will add schema validation related stuff in a separate PR ~

@mj12albert mj12albert merged commit 422a4de into mui:master Nov 12, 2025
20 checks passed
@mj12albert mj12albert deleted the docs/forms-guide branch November 12, 2025 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to the documentation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[form][docs] React Hook Form guide/tutorial

9 participants