Radio
Radio components provide users a way to select only one option from a list of two or more options.
Text for testing custom content.
Bordered Radio
Sage Component
SageRadio
<!-- Default -->
<%= sage_component SagePanelStack, {} do %>
<%= sage_component SageRadio, {
id: "r1",
name: "radio1",
value: "1",
label_text: "Option 1",
checked: true
} %>
<%= sage_component SageRadio, {
id: "r2",
name: "radio1",
value: "2",
label_text: "Option 2"
} %>
<%= sage_component SageRadio, {
id: "r2b",
name: "radio1",
value: "2b",
label_text: "Option 2b",
message: "Message text goes here.",
} do %>
<%= content_for :sage_radio_custom_content do %>
<p>Text for testing custom content.</p>
<% end %>
<% end %>
<!-- Disabled -->
<%= sage_component SageRadio, {
id: "r3",
name: "radio2",
value: "3",
label_text: "Disabled",
disabled: true
} %>
<!-- Checked & Disabled -->
<%= sage_component SageRadio, {
id: "r4",
name: "radio3",
value: "4",
label_text: "Checked & Disabled",
checked: true,
disabled: true
} %>
<!-- Error -->
<%= sage_component SageRadio, {
id: "r5",
name: "radio4",
value: "5",
label_text: "Error",
required: true,
has_error: true
} %>
<% end %>
<h3 class="t-sage-heading-6">Bordered Radio</h3>
<%= sage_component SageRadio, {
caption: "caption text",
id: "r6",
name: "radio5",
value: "6",
has_border: true,
label_text: "Bordered Option",
required: true,
} do %>
<%= content_for :sage_radio_custom_content do %>
<%= sage_component SageBadge, {
value: "Published",
color: "published",
}%>
<% end %>
<% end %>
<%= sage_component SageRadio, {
caption: "caption text",
id: "r7",
name: "radio6",
value: "7",
label_text: "Bordered Option with Error",
required: true,
has_border: true,
has_error: true
} %>
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 caption text for the component in a bordered card. |
String |
|
|
Sets the state of the radio button to |
Boolean |
|
|
Prevents all user interaction with the control. Be aware that when combining a disabled radio button with a default |
Boolean |
|
|
When set, the focus styles affect the parent container, not the form element. |
Boolean |
|
|
This will display error styles on the component. |
Boolean |
|
|
Unique identifier for this input field. Should match the |
String |
|
|
Sets the label text for the component. |
String |
|
|
Sets the message text for the component in the default, unbordered context. |
String |
|
|
Using a singular name groups radio buttons together, allowing the user to toggle between them (see Option 1 and Option 2 examples above) |
String |
|
|
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 radio. |
- Verify that the ID of the input and the label's
for
attribute match
- Combine the
checked
&disabled
states with caution! Clearly describe why this item cannot be unselected.