Checkbox
Checkboxes provide users with selectable options like toggling a single setting or selecting multiple options from a list.
Default:
Disabled:
Error:
Custom content:
Paragraph for testing custom content.
Sage Component
SageCheckbox
<!-- Default -->
<%= sage_component SagePanelStack, { spacing: "form" } do %>
<h3 class="t-sage-heading-6">Default:</h3>
<%= sage_component SageCheckbox, {
id:"c1",
label_text: "Label text",
} %>
<%= sage_component SageCheckbox, {
id:"c2",
label_text: "Partial",
partial_selection: true
} %>
<%= sage_component SageCheckbox, {
id:"c3",
label_text: "Checked",
checked: true,
} %>
<%= sage_component SageCheckbox, {
id:"c4",
label_text: "Checkbox w/ Message",
message: 'This is where a "hint" message would appear.',
} %>
<h3 class="t-sage-heading-6">Disabled:</h3>
<%= sage_component SageCheckbox, {
id:"c5",
label_text: "Label text",
disabled: true,
} %>
<%= sage_component SageCheckbox, {
id:"c6",
label_text: "Partial",
partial_selection: true,
disabled: true,
} %>
<%= sage_component SageCheckbox, {
id:"c7",
label_text: "Checked",
checked: true,
disabled: true,
} %>
<%= sage_component SageCheckbox, {
id:"c8",
label_text: "Checkbox w/ Message",
message: 'This is where a "hint" message would appear.',
disabled: true,
} %>
<h3 class="t-sage-heading-6">Error:</h3>
<%= sage_component SageCheckbox, {
id:"c9",
label_text: "Label text",
has_error: true,
} %>
<%= sage_component SageCheckbox, {
id:"c10",
label_text: "Partial",
partial_selection: true,
has_error: true,
} %>
<%= sage_component SageCheckbox, {
id:"c11",
label_text: "Checked",
checked: true,
has_error: true,
} %>
<%= sage_component SageCheckbox, {
id:"c12",
label_text: "Checkbox w/ Message",
message: 'This is where a "hint" message would appear.',
has_error: true,
} %>
<h3 class="t-sage-heading-6">Custom content:</h3>
<%= sage_component SageCheckbox, {
id:"c13",
label_text: "Checkbox",
checked: false,
disabled: false,
has_error: false,
message: 'This is where a "hint" message would appear.',
} do %>
<% content_for :sage_checkbox_custom_content do %>
<p>Paragraph for testing custom content.</p>
<% end %>
<% end %>
<% end %>
Property | Description | Type | Default |
---|---|---|---|
|
For setting additional attributes not defined above. Accepts a Ruby hash of valid key-value properties, such as data-attributes |
Hash |
|
|
Sets the state to "checked" by default |
String |
|
|
Prevents all user interaction with the control. Be aware that when combining a disabled checkbox with a default "checked" state, the value of the checkbox will not be included when its parent form is submitted. Likewise, setting Required will not have any effect. |
String |
|
|
This will display error styles on the component. |
Boolean |
|
|
Unique identifier for the checkbox. Should match the "for" attribute on the corresponding label |
String |
|
|
Sets the label text for the component. |
String |
|
|
Sets the message text for the component. |
String |
|
|
See MDN Web Docs for details on checkbox name attribute |
String |
|
|
When set, adds styling to show that now all elements are selected |
Boolean |
|
|
Adding this attribute allows basic HTML form validation on this field |
Boolean |
|
|
When set, this component is expected to be used in isolation. |
Boolean |
|
|
Sets the value of the form component. |
String |
|
Content Slots | |||
|
Slot for any custom content below the checkbox. |