---
description: 'How to build forms with ranui: r-input, r-checkbox, and r-select work directly inside a plain native
` CSS
> (`display: flex; flex-direction: column; gap: …`). Omitting it stacks fields in plain
> in-flow order with no spacing between them, which reads as broken/overlapping rather than
> a form.
```html
MemberAdminSubscribe to newsletter
```
## `serializeForm(form)`
Collects a `
`'s named fields into a plain object via `FormData`: the boilerplate every consumer otherwise hand-rolls to turn a submit into something they can `JSON.stringify` or send as a fetch body. It's a plain function with no dependency on ranui fields specifically; it works with any real `
`.
```ts
function serializeForm(form: HTMLFormElement): Record;
```
A field with more than one value under the same `name` (e.g. multiple checkboxes sharing a name) comes back as an array; everything else comes back as a single value.
```ts
import { serializeForm } from 'ranui';
const data = serializeForm(document.querySelector('form'));
// { username: 'alice', tags: ['a', 'b'] }
fetch('/api/signup', { method: 'POST', body: JSON.stringify(data) });
```
## Layout {#layout}
Fields have no default form-level layout: style your own `
` with plain CSS:
```html
```
## Validation and reset
`r-input`, `r-checkbox`, and `r-select` all support `required` (which blocks submission and triggers the browser's native validation bubble, exactly like a native field) plus `checkValidity()`, `reportValidity()`, `validity`, and `validationMessage`. A native `form.reset()` (or `