If you're one of those who think we should just use the default, bear in mind that the default radio button has poor usability for mobile users.
I'd be curious to know more about the usability issues you've found on mobile -- I've not had any personally when using radio buttons. I'll readily grant you that 'select' is awful everywhere though!
Wrap it in a label, give the label a padding. Boom!
Then if you want something a little bit complicated you have to do it all yourself.
- What if I need a date range instead of a single date? - What if I have excluded dates? (Only weekdays/only in the future/blackout dates) - What if I want to show other metadata with each day? (Like in a calendar showing each day with some metadata next to it)
Beyond “give a whatever the system thinks is a good date picker that I have no control over” the input with type date isn’t very useful.
It gives a very naive approach that doesn’t support any complex styling.
For that you need to wrap the input and additional styling elements in a ref’ed label.
By using radix, the underlying behaviour is compliant and identical for each of those implementations - you just change the content. Radix isn't looking at it like an html radio element, it is looking at it as a completely unstyled unique item selector.
The pseudo-element styling approach limits you to 3 layers - the container, and the 2 pseudo elements, none of which you can provide with meaningful content besides plain text. The best you can do is provide a basic styles and set background image. For anything else you need to use labels to either wrap the radio (in which case you can access state via sibling selectors) and/or ref them with "for" (in which case you cant access the state).
Putting an adjacent label is also possible, but scales poorly due to needing unique ids.
I'd be happy to implement an HTML + CSS only solution and share it with you.
Thanks