Replies: 1 comment
|
https://github.com/search?q=repo%3ATextualize%2Ftextual%20%3Adisabled&type=code |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Problem
Widgets like
RadioButton,Select, andCheckboxalready supportdisabled=Trueat the Python level — the widget ignores clicks and keyboard events correctly. But there is no way to style disabled items differently via TCSS. The:disabledCSS pseudo-class used in web CSS (input:disabled { color: gray; }) has no equivalent in Textual CSS.This means every app that wants to show "coming soon" or unavailable options in a choice list has to work around it manually — add custom classes, use custom widgets, or hack at color properties.
The result: disabled choices look identical to active ones, confusing users about what they can and cannot select.
Proposal
Add
:disabledas a recognized pseudo-class in the TCSS parser and selector matcher. It would match any widget whosedisabledproperty is truthy.Why this works
The plumbing is already there —
Widget.disabledis a reactive attribute on the base class, andRadioButton,Select,Checkbox,Button,Input, and many others already honor it for event handling. The CSS engine just needs to expose it as a queryable pseudo-class, similar to how:focusand:hoveralready work today.Real-world use case (studiolot)
We have an onboarding wizard with a
RadioSetlisting 8 AI providers. One is active (Replicate), and 7 are grayed-out as "coming soon" entries so users can see the roadmap. Without:disabled, we have to manually attach a.radio-disabledCSS class to each disabledRadioButton:With
:disabledsupport, this becomes pure TCSS — no Python-level class management needed:I would like to build this
Happy to submit a PR. The work would touch the TCSS parser (recognizing
:disabledas a valid pseudo-class) and the selector matcher (checkingself.disabledduring widget matching). I will need a pointer on where in the Textual codebase the pseudo-class dispatch lives, but I am ready to do the implementation.All reactions