Skip to content
This repository was archived by the owner on May 11, 2026. It is now read-only.

Commit 2a41330

Browse files
committed
aria-disabled for RadioButton
1 parent bdd19ec commit 2a41330

3 files changed

Lines changed: 27 additions & 2 deletions

File tree

app/components/ruby_ui/form/form_field_label.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ def view_template(&)
99
private
1010

1111
def default_attrs
12-
{class: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"}
12+
{
13+
class: [
14+
"text-sm font-medium leading-none",
15+
"peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
16+
"peer-aria-disabled:cursor-not-allowed peer-aria-disabled:opacity-70 peer-aria-disabled:pointer-events-none"
17+
]
18+
}
1319
end
1420
end
1521
end

app/components/ruby_ui/radio_button/radio_button.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ def default_attrs
1717
},
1818
class: [
1919
"h-4 w-4 p-0 border-primary rounded-full flex-none",
20-
"disabled:cursor-not-allowed disabled:opacity-50"
20+
"disabled:cursor-not-allowed disabled:opacity-50",
21+
"aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:pointer-events-none"
2122
]
2223
}
2324
end

app/views/docs/radio_button.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,24 @@ def view_template
2727
RUBY
2828
end
2929

30+
render Docs::VisualCodeExample.new(title: "Disabled", context: self) do
31+
<<~RUBY
32+
div(class: "flex flex-row items-center gap-2") do
33+
RadioButton(id: "disabled", disabled: true)
34+
FormFieldLabel(for: "disabled") { "Disabled" }
35+
end
36+
RUBY
37+
end
38+
39+
render Docs::VisualCodeExample.new(title: "Aria Disabled", context: self) do
40+
<<~RUBY
41+
div(class: "flex flex-row items-center gap-2") do
42+
RadioButton(class: "peer", id: "aria-disabled", aria: {disabled: "true"})
43+
FormFieldLabel(for: "aria-disabled") { "Aria Disabled" }
44+
end
45+
RUBY
46+
end
47+
3048
render Components::ComponentSetup::Tabs.new(component_name: component)
3149

3250
render Docs::ComponentsTable.new(component_files(component))

0 commit comments

Comments
 (0)