Skip to content

Support passing in direction to useSlider for media controls #10112

Description

@ewlsh

Provide a general summary of the feature here

This is the same ask as #2315 but for a different reason. For sliders that are used for media (e.g. an audio progress bar) they will always be left-to-right (ltr). See "Media Players" in https://m3.material.io/foundations/layout/bidirectionality-rtl for a good explanation of this.

Right now in our application we're doing this:

const { locale, direction } = useLocale();

 return (
  <I18nProvider locale={direction === 'rtl' ? 'en-US' : locale}>
     <Slider ... />
  </I18nProvider>
);

...to hackily workaround the limitation highlighted in #2315

🤔 Expected Behavior?

Support indicating the direction of a slider independently from the current locale.

😯 Current Behavior

Currently the direction of the slider is tied to the current locale - but in right-to-left languages there are left-to-right sliders.

💁 Possible Solution

Ideally we could provide a direction prop which controls reverseX independently of I18nProvider so that we can avoid overriding the locale given that has other formatting implications:

    const { ... } = useSlider(
        {
           direction: 'ltr',
        },
        state,
        trackRef,
    );

An alternative version of this could be a reversed property which defaults to true for direction === 'rtl':

    const { ... } = useSlider(
        {
           reversed: false,
        },
        state,
        trackRef,
    );

🔦 Context

See "Media Players" in https://m3.material.io/foundations/layout/bidirectionality-rtl for a good explanation of this.

💻 Examples

No response

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions