Skip to content

Various form components Checkbox, etc. do not support form prop per native HTML attribute #4334

@firxworx

Description

@firxworx

Bug report

Checkbox, Radio/RadioGroup, etc. do not accept the form prop.

I believe they should and that they should and apply it to the underlying hidden inputs managed by Base UI.

The form prop is accepted on Base UI Input and correctly applied to the <input> element as I expect.

This important native HTML attribute is accepted on <button>, <fieldset>, <input>, <object>, <output>, <select>, and <textarea> elements and explicitly associates them with a given form even when they are not children of that form.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/form

I am pretty new to Base UI so I apologize if I am misunderstanding and you think I should be custom render , etc.

However it strikes me from where I am at that this is something I expected to work for simple input components without getting fancy.

Current behavior

Base UI (or at least its types) do not support setting form except in isolated case such as Input.

Expected behavior

I expect to be able to set form to associate the underlying input with the id of the form it belongs to.

This expectation is reinforced because Base UI's other form-related components accept other standard props/attributes and handle them correctly.

The form prop can be huge for complex UI's with multiple forms, nested forms, forms in modals / React portals, integrating with React form libraries, etc. and can really help smooth things with certain frameworks such as react-router / remix in various cases.

Reproducible example

Trivial to reproduce in any current project with Base UI.

For example try setting form on <Checkbox.Root form="my-form-id" />

Base UI version

Confirmed in current release 1.3.0 as well as earlier 1.x releases/

Which browser are you using?

N/A

Which OS are you using?

N/A

Which assistive tech are you using (if applicable)?

N/A

Additional context

Provide any additional context that might help us identify the problem and find a solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions