跳到主要内容

Checks and radios

Create consistent cross-browser and cross-device checkboxes and radios with our completely rewritten checks component.

For the non-textual checkbox and radio controls, FormCheck provides a single component for both types that adds some additional styling and improved layout.

Default (stacked)

By default, any number of checkboxes and radios that are immediate sibling will be vertically stacked and appropriately spaced with FormCheck.

结果
Loading...
实时编辑器

Switches

A switch has the markup of a custom checkbox but uses type="switch" to render a toggle switch. Switches also support the same customizable children as <FormCheck>.

结果
Loading...
实时编辑器

Inline

Group checkboxes or radios on the same horizontal row by adding the inline prop.

结果
Loading...
实时编辑器

Reverse

Put your checkboxes, radios, and switches on the opposite side with the reverse prop.

结果
Loading...
实时编辑器

Without labels

When you render a FormCheck without a label (no children) some additional styling is applied to keep the inputs from collapsing.

Remember to add an aria-label when omitting labels!

结果
Loading...
实时编辑器

Customizing FormCheck rendering

When you need tighter control, or want to customize how the FormCheck component renders, it may better to use its constituent parts directly.

By provided children to the FormCheck you can forgo the default rendering and handle it yourself. (You can still provide an id to the FormCheck or FormGroup and have it propagate to the label and input).

结果
Loading...
实时编辑器

API

FormCheck

FormCheckInput

FormCheckLabel