Checkbox
A checkbox is an input control that allows a user to select one or more options from a number of choices.
Code
Variants
certara-checkbox
is best used inside a certara-form-group
.
Help or instructional text goes here
Optional help link
certara-checkbox
Properties
Property | Attribute | Description | Type | Default |
---|---|---|---|---|
checked | checked | boolean | false | |
disabled | disabled | boolean | false | |
indeterminate | indeterminate | boolean | false | |
inputType | input-type | Internal prop to make a radio button. Best to use the certara-radio component directly | "checkbox" | "radio" | 'checkbox' |
layout | layout | Layout options for stacked or inline checkboxes | "inline" | "stacked" | 'inline' |
name | name | string | undefined | |
size | size | "md" | "sm" | 'md' | |
value | value | any | 'on' |
Events
Event | Description | Type |
---|---|---|
certaraBlur | Standard event emitted when checkbox is blurred | CustomEvent<void> |
certaraChange | Standard event emitted when checkbox is toggled | CustomEvent<CheckboxChangeEventDetail<any>> |
certaraFocus | Standard event emitted when checkbox is focused | CustomEvent<void> |
Slots
Slot | Description |
---|---|
Content for the label | |
"error" | Error text that sits below the label |
"help" | Help text that sits below the label |
Dependencies
Used by
Depends on
Graph
graph TD; certara-checkbox --> certara-help-block certara-dropdown-checkbox --> certara-checkbox certara-radio --> certara-checkbox style certara-checkbox fill:#f9f,stroke:#333,stroke-width:4px
Symbols prefixed by underscore ("_")
When referencing/naming Symbol with a form input, any argument/option/variable that are endemic to the input itself (i.e. "id", "placeholder", "required") are **not** preceded by an _underscore. In other cases, an _underscore precedes to denote it affects the output of a container/parent element, or a sibling.
@standardCheckbox(myForm(""), Symbol("_label") -> "", Symbol("id") -> "", Symbol("_inline") -> false, Symbol("_help") -> "", Symbol("_helpLink") -> Symbol("disabled") -> false, Symbol("checked") -> false, Symbol("class") -> "", Symbol("_class") -> "",)
NameTypeDescriptionDefault valueCopy
- _labelstringText that describes the control. Will be both visible and clickable.blank
- idstring (required)adds an id to the
input
and a for attribute to the associated labellabel
blank - _inlineboolean
true
invokes the inline visual permutationfalse - disabledbooleanSets the field as to appear disabled, users will not be able to interact with the text field.false
- checkedbooleanspecifies that the
input
element should be pre-selected (checked) when the page loads.false - classstringadds
class=""
to the inputblank - _classstringadds
class=""
to the container div (.form-check
)blank - _helpstringoutputs additional help or instructional textblank
- _helpLinkhtml block (no quotes)appends a link to help or instructional textblank
In Practice
Checkboxes should:
- Work independently from each other. Selecting one checkbox shouldn’t change the selection status of another checkbox in the list. The exception is when a checkbox is used to make a bulk selection of multiple items.
- Be framed positively. For example, say “Show file path for uploaded data” instead of “Hide file path for uploaded data”.
- Always have a label when used to activate or deactivate a setting.
- Be listed according to a logical order, whether it’s alphabetical, numerical, time-based, or some other clear system.
- Link to more information or include a subtitle as required to provide more explanation. Don’t rely on tooltips to explain a checkbox.
Content guidelines
Labels
- Keep checkbox labels short and descriptive.
- Start all checkbox labels with a capital letter.
- Don’t include punctuation after checkbox labels.
Accessibility
Keyboard support
- Move focus to each checkbox using the tab key (or shift + tab when tabbing backwards).
- To interact with the checkbox when it has keyboard focus, press the space key.