🙋 Feature Request
Currently, useSlider and useSliderThumb use useLocale to get direction. I'd like to request a direction (or dir) parameter to be able pass in useSlider and useSliderThumb so that we don't need to reply on useLocale to get the direction for LTR/RTL.
🤔 Expected Behavior
If the direction parameter is provided, it override the direction of useLocale.
😯 Current Behavior
Current behavior is that we must use <I18nProvider> to specify locale for the direction.
💁 Possible Solution
Add an optional dir parameter in useSlider and useSliderThumb.
/**
* Provides behavior and accessibility for a thumb of a slider component.
*
* @param opts Options for this Slider thumb.
* @param state Slider state, created via `useSliderState`.
* @param dir Direction for this Slider thumb.
*/
export function useSliderThumb(
opts: SliderThumbOptions,
state: SliderState,
dir?: Direction
): SliderThumbAria {
const { index, isRequired, isDisabled, validationState, trackRef, inputRef } =
opts;
const isVertical = opts.orientation === "vertical";
let { direction } = useLocale();
direction = dir ?? direction;
...
}
Same for useSlider. So we can use our theme direction.
const theme = useTheme();
const { thumbProps, inputProps } = useSliderThumb(
{
index,
trackRef,
inputRef
},
state,
theme.direction
);
🔦 Context
Our system is using ThemeProvider with theme direction directly, it's difficult to convert direction to locale and use <I18nProvider>, so we can't make the useSlider and useSliderThumb work correctly for RTL. It would be great that if they have direction parameter to be more flexible to use.
I am not sure if there is any other way to make them work correctly for RTL, except using <I18nProvider>. Please let me know if there is a better way to do that.
If this proposed change makes sense to you guys, I am happy to prepare the pull request. Thank you. 🙇♀️
🙋 Feature Request
Currently,
useSlideranduseSliderThumbuseuseLocaleto getdirection. I'd like to request adirection(ordir) parameter to be able pass inuseSlideranduseSliderThumbso that we don't need to reply onuseLocaleto get thedirectionfor LTR/RTL.🤔 Expected Behavior
If the
directionparameter is provided, it override thedirectionofuseLocale.😯 Current Behavior
Current behavior is that we must use
<I18nProvider>to specify locale for thedirection.💁 Possible Solution
Add an optional
dirparameter inuseSlideranduseSliderThumb.Same for
useSlider. So we can use our theme direction.🔦 Context
Our system is using ThemeProvider with theme direction directly, it's difficult to convert direction to locale and use
<I18nProvider>, so we can't make theuseSlideranduseSliderThumbwork correctly for RTL. It would be great that if they havedirectionparameter to be more flexible to use.I am not sure if there is any other way to make them work correctly for RTL, except using
<I18nProvider>. Please let me know if there is a better way to do that.If this proposed change makes sense to you guys, I am happy to prepare the pull request. Thank you. 🙇♀️