Radio is a control that allows the user to only choose one predefined option.
<%= pb_rails("radio", props: { text: "Power", input_options: { tabindex: 0 }, name: "group 1", value: "Power" }) %> <br> <%= pb_rails("radio", props: { text: "Nitro", name: "group 1", value: "Nitro" }) %> <br> <%= pb_rails("radio", props: { text: "Google", name: "group 1", value: "Google" }) %>
<%= pb_rails("radio", props: { text: "Power" }) do %> <input type="radio" name="group 3" value="power" > <% end %> <br> <%= pb_rails("radio", props: { text: "Nitro" }) do %> <input type="radio" name="group 3" value="nitro" checked> <% end %> <br> <%= pb_rails("radio", props: { text: "Google" }) do %> <input type="radio"name="group 3" value="google"> <% end %>
Error shows that the radio option must be selected or is invalid (i.e. when used in a form it signals a user to fix an error).
<%= pb_rails("flex") do %> <%= pb_rails("radio", props: { alignment: "vertical", text: "Power", input_options: { tabindex: 0 }, margin_right: "sm", name: "group 1", value: "Power" }) %> <%= pb_rails("radio", props: { alignment: "vertical", text: "Nitro", margin_right: "sm", name: "group 1", value: "Nitro" }) %> <%= pb_rails("radio", props: { alignment: "vertical", text: "Google", name: "group 1", value: "Google" }) %> <% end %>
<%= pb_rails("flex", props: {orientation: "column"}) do %> <%= pb_rails("flex/flex_item") do %> <%= pb_rails("radio", props: { text: "Disabled unselected", input_options: { tabindex: 0, disabled: true, }, margin_bottom: "xs", name: "DisabledGroup", value: "Disabled unselected", }) %> <% end %> <%= pb_rails("flex/flex_item") do %> <%= pb_rails("radio", props: { text: "Disabled selected", input_options: { tabindex: 0, disabled: true, }, checked: true, name: "DisabledGroup", value: "Disabled selected" }) %> <% end %> <% end %>
Use the custom_children prop to enable the use of kits instead of text labels.
<% options = [ { label: "Orange", value: "Orange" }, { label: "Red", value: "Red" }, { label: "Green", value: "Green" }, { label: "Blue", value: "Blue" }, ] %> <%= pb_rails("radio", props: { custom_children: true, label: "Select", margin_bottom: "sm", name: "Group1", value: "Select", }) do %> <%= pb_rails("select", props: { min_width: "xs", options: options, }) %> <% end %> <%= pb_rails("radio", props: { custom_children: true, label: "Typeahead", margin_bottom: "sm", name: "Group1", value: "Typeahead", }) do %> <%= pb_rails("typeahead", props: { id: "typeahead-radio", is_multi: false, min_width: "xs", options: options, placeholder: "Select...", }) %> <% end %> <%= pb_rails("radio", props: { custom_children: true, label: "Typography", name: "Group1", value: "Typography", }) do %> <%= pb_rails("title", props: { text: "Custom Typography", }) %> <% end %>
| Props | Type | Values |
|---|---|---|
align_content |
enum | responsive
|
start
end
center
spaceBetween
spaceAround
spaceEvenly
|
align_items |
enum | responsive
|
start
end
center
|
border_radius |
enum
|
none
xs
sm
md
lg
xl
rounded
|
cursor |
enum
|
auto
default
none
contextMenu
help
pointer
progress
wait
cell
|
dark |
boolean
|
true
false
|
flex |
enum | responsive
|
auto
initial
0
1
2
3
4
5
6
7
8
9
10
11
12
none
|
flex_direction |
enum | responsive
|
row
column
rowReverse
columnReverse
|
flex_wrap |
enum | responsive
|
wrap
nowrap
wrapReverse
|
justify_content |
enum | responsive
|
start
end
center
spaceBetween
spaceAround
spaceEvenly
|
line_height |
enum
|
loosest
looser
loose
normal
tight
tighter
tightest
|
margin_right |
array
|
none
xxs
xs
sm
md
lg
xl
|
margin_left |
array
|
none
xxs
xs
sm
md
lg
xl
|
margin_top |
array
|
none
xxs
xs
sm
md
lg
xl
|
margin_bottom |
array
|
none
xxs
xs
sm
md
lg
xl
|
margin_x |
array
|
none
xxs
xs
sm
md
lg
xl
|
margin_y |
array
|
none
xxs
xs
sm
md
lg
xl
|
margin |
array
|
none
xxs
xs
sm
md
lg
xl
|
width |
string
|
|
min_width |
string
|
|
max_width |
string
|
|
gap |
string | responsive
|
|
column_gap |
string | responsive
|
|
row_gap |
string | responsive
|
|
number_spacing |
enum
|
tabular
|
order |
enum | responsive
|
none
first
1
2
3
4
5
6
7
8
9
10
11
12
|
overflow_x |
enum
|
scroll
visible
hidden
auto
|
overflow_y |
enum
|
scroll
visible
hidden
auto
|
overflow |
enum
|
scroll
visible
hidden
auto
|
padding_right |
array
|
none
xxs
xs
sm
md
lg
xl
|
padding_left |
array
|
none
xxs
xs
sm
md
lg
xl
|
padding_top |
array
|
none
xxs
xs
sm
md
lg
xl
|
padding_bottom |
array
|
none
xxs
xs
sm
md
lg
xl
|
padding_x |
array
|
none
xxs
xs
sm
md
lg
xl
|
padding_y |
array
|
none
xxs
xs
sm
md
lg
xl
|
padding |
array
|
none
xxs
xs
sm
md
lg
xl
|
position |
enum
|
relative
absolute
fixed
sticky
static
|
shadow |
enum
|
none
deep
deeper
deepest
|
text_align |
enum | responsive
|
start
end
left
right
center
justify
justifyAll
matchParent
|
truncate |
enum
|
none
1
2
3
4
5
|
vertical_align |
enum | responsive
|
baseline
super
top
middle
bottom
sub
text-top
text-bottom
|
z_index |
enum | responsive
|
1
2
3
4
5
6
7
8
9
10
max
|
top |
enum | object
|
xxs
xs
sm
md
lg
xl
xxl
|
inset |
boolean
|
true
false
|
right |
enum | object
|
xxs
xs
sm
md
lg
xl
xxl
|
bottom |
enum | object
|
xxs
xs
sm
md
lg
xl
xxl
|
left |
enum | object
|
xxs
xs
sm
md
lg
xl
xxl
|
height |
string
|
|
max_height |
string
|
|
min_height |
string
|
|
hover |
object
|
|
group_hover |
boolean
|
true
false
|
| Props | Type | Values | Default |
|---|---|---|---|
alignment |
string
|
||
checked |
boolean, // removed default assignment here
|
false
|
|
custom_children |
boolean
|
true
false
|
false
|
disabled |
boolean
|
true
false
|
false
|
error |
boolean
|
true
false
|
false
|
label |
string
|
||
name |
string
|
radio_name
|
|
value |
string
|
radio_text
|
|
text |
string
|
Radio Text
|
|
on_change |
(event: react.formevent<htmlinputelement> | null) => void
|
||
input_options |
string
|