Example of separating triggers, labels and messages from core fields? #4752
-
Ive noticed in the new react-aria-components lib that there's the capacity to split the parts of a field into constituent elements to have a little more control over where something is rendered. Ive been working with react-aria exclusively for the last year and it is always me accepting the hooks api, then getting frustrated with the tight coupling of triggers, labels and descriptions to the specific field mechanics which prevents me from having the layout or styling freedom that makes headless ui and radix attractive....then ill look into radix or headless ui as an alternative, realise they're not even in the same ballpark as far as accessibility goes and neither have a good calendar component, then ill resign myself to react-aria's hooks and go full material-ui on the overrides to provide a modicum of styling and layout flexibility with my fields. Is there any examples and is it even possible with the current hooks to perhaps leverage a local react context in a way that provides this kind of flexibility? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Just to be clear, you want to have a component structure like what react aria components allows instead of an implementation like the aria hooks docs show? Do you have an example illustrating the issue you are running into with the hooks here? Is it mainly to do with propagating the various props (e.g. labelProps, errorMessageProps, etc) that are returned by the hooks to their respective Label/Text elements that would be added by the user rather than being rendered as a part of the component inherently? If so, you could perhaps mimic how the react aria components pass those props via context. Alternatively, is there something the current react aria components implementation doesn't offer that you find yourself dropping down to the hooks level to implement instead? |
Beta Was this translation helpful? Give feedback.
Hopefully when #4616 is release, the above should be easier for you to do since the parent wrapper of the RAC Select will have things like isFocused available.
As for the issue with select where the collection children may not be the immediate child of the component calling
useSelectState
, you can checkout how we handled this in RAC Select here. We ins…