Overview
A custom 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>
.
You can also use the <Form.Switch>
alias which encapsulates the above, in a very small component wrapper.
Example
Inline
API
Form
import Form from `@trimbleinc/modus-react-bootstrap/Form`
Name | Type | Default | Description |
---|---|---|---|
ref | ReactRef | The Form | |
as | elementType | <form> | |
inline | boolean | false | Display the series of labels, form controls, and buttons on a single horizontal row |
validated | boolean | Mark a form as having been validated. Setting it to | |
bsPrefix | string | {'form'} |
Form.Check
import Form.Check from `@trimbleinc/modus-react-bootstrap/Form.Check`
Name | Type | Default | Description |
---|---|---|---|
ref | ReactRef | The FormCheck | |
as | 'input' | elementType | 'input' | The underlying HTML element to use when rendering the FormCheck. |
children | node | Provide a function child to manually handle the layout of the FormCheck's inner components.
| |
custom | all(PropTypes.bool, ({ custom, id }) =>
custom && !id ? Error('Custom check controls require an id to work') : null,
) | Use Bootstrap's custom form elements to replace the browser defaults | |
disabled | boolean | false | Disables the control. |
feedback | node | A message to display when the input is in a validation state | |
feedbackTooltip | boolean | false | Display feedback as a tooltip. |
id | string | A HTML id attribute, necessary for proper form accessibility. An id is recommended for allowing label clicks to toggle the check control. This is required for custom check controls or when | |
inline | boolean | false | Groups controls horizontally with other |
isInvalid | boolean | false | Manually style the input as invalid |
isValid | boolean | false | Manually style the input as valid |
label | node | Label for the control. | |
title | string | '' |
|
type | 'radio' | 'checkbox' | 'switch' | 'checkbox' | The type of checkable. |
bsPrefix | string | 'form-check' | |
bsCustomPrefix | string | 'custom-control' | A seperate bsPrefix used for custom controls |
FormCheck.Input
import FormCheck.Input from `@trimbleinc/modus-react-bootstrap/FormCheck.Input`
Name | Type | Default | Description |
---|---|---|---|
as | 'input' | elementType | 'input' | The underlying HTML element to use when rendering the FormCheckInput. |
id | string | A HTML id attribute, necessary for proper form accessibility. | |
isInvalid | boolean | false | Manually style the input as invalid |
isStatic | boolean | A convenience prop shortcut for adding | |
isValid | boolean | false | Manually style the input as valid |
type | 'radio' | 'checkbox' | 'checkbox' | The type of checkable. |
bsPrefix | string | 'form-check-input' | |
bsCustomPrefix | string | 'custom-control' | A seperate bsPrefix used for custom controls |