Skip to content

Commit 07b076b

Browse files
feat(accessibility): add consistent focus indicators for UI elements (#141)
Implements task UI-3. Adds a consistent, high-visibility 3px focus ring to all interactive elements, including buttons, links, inputs, and accordions. - Uses the modern `:focus-visible` pseudo-class to apply focus styles only for keyboard navigation, avoiding outlines on mouse clicks. - Replaces hardcoded colors with Gradio theme variables (e.g., `var(--primary-200)`) to ensure the feature is compatible with theming and dark mode. - Cleans up a redundant, pre-existing focus style for text inputs that used hardcoded colors. This change significantly improves keyboard navigation and overall accessibility of the application. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent 9f6f549 commit 07b076b

1 file changed

Lines changed: 30 additions & 8 deletions

File tree

src/ui/theme.py

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,36 @@
4343
margin: 0 auto !important;
4444
}
4545
46+
/* --- Accessibility: Focus Indicators (UI-3) --- */
47+
/*
48+
Adds a consistent, high-visibility 3px focus ring for keyboard users.
49+
- Uses :focus-visible for buttons etc. to avoid rings on mouse clicks.
50+
- Uses a standard :focus for text inputs as is conventional.
51+
- Uses theme variables for colors to support dark mode.
52+
*/
53+
:is(
54+
button,
55+
a,
56+
[role="button"],
57+
.tab-nav button,
58+
details summary,
59+
input[type="file"]
60+
):focus-visible {
61+
outline: none !important;
62+
box-shadow: 0 0 0 3px var(--primary-200) !important;
63+
border-color: var(--primary-600) !important;
64+
}
65+
66+
/* Special handling for text inputs to merge with existing style */
67+
input[type="text"]:focus,
68+
textarea:focus,
69+
select:focus {
70+
border-color: var(--primary-500) !important;
71+
box-shadow: 0 0 0 3px var(--primary-200) !important;
72+
outline: none !important;
73+
}
74+
/* --- End Accessibility --- */
75+
4676
/* Tab styling */
4777
.tabs {
4878
border-bottom: 2px solid #e5e7eb;
@@ -158,14 +188,6 @@
158188
transition: all 0.2s !important;
159189
}
160190
161-
input[type="text"]:focus,
162-
textarea:focus,
163-
select:focus {
164-
border-color: #6366f1 !important;
165-
box-shadow: 0 0 0 3px rgb(99 102 241 / 0.1) !important;
166-
outline: none !important;
167-
}
168-
169191
/* File upload styling */
170192
.file-upload {
171193
border: 2px dashed #d1d5db;

0 commit comments

Comments
 (0)