Skip to content

"rtl" style for the select element #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
let-lc opened this issue Oct 23, 2021 · 2 comments
Closed

"rtl" style for the select element #86

let-lc opened this issue Oct 23, 2021 · 2 comments

Comments

@let-lc
Copy link

let-lc commented Oct 23, 2021

What version of @tailwindcss/forms are you using?

v0.3.4

What version of Node.js are you using?

v14.0.0

What browser are you using?

Chrome, Firefox

What operating system are you using?

Windows

Reproduction repository

https://github.com/let-lc/tailwindcss-forms/tree/rtl-issue-reproduction

Describe your issue

I recently work on a project that needs to change the direction to "rtl" when changing the site language to Arabic, and the project has the tailwindcss-forms plugin installed. I noticed all the form elements I used are rendering "rtl" normally except the <select> element.

A raw, no styles select element with "rtl" direction displays the chevron down icon on the left side, shows here https://play.tailwindcss.com/lORpOqPWap. However, the tailwindcss-form plugin always has the icon displaying on the right side.

In the reproduction branch, I set the "Unstyled" section to "rtl" to show the issue.

I think we should have the select element resemble the "rtl" style of a raw,no styles select element by putting the chevron icon on the left side. I currently overrided some styles of the tailwindcss-form to fix the issue in my project, but I think this should be supported by the plugin natively.

I already worked on a solution and ready to submit a PR, but I know the contributing guidelines is issue first then PR, so here's description for the issue.

And here is the "ltr" and "rtl" comparison I worked on:
select-rtl

@y1n0
Copy link

y1n0 commented Feb 11, 2022

Yes please, this is basically a bug, it should be fixed
here is how it displays a select element for me in ltr vs rtl:
Screen Shot 2022-02-11 at 12 01 57
Screen Shot 2022-02-11 at 12 02 05
the arrow should always be in the end of the line

@adamwathan
Copy link
Member

Hey! Right now we don't explicitly support RTL layouts automatically. If you'd like to customize the default styles, the recommendation is to just write custom CSS.

If your entire site is RTL, you can override the default position for the chevron with something like this:

@layer base {
  select {
    background-position: left theme('spacing.2') center;
    padding-left: theme('spacing.10');
    padding-right: theme('spacing.3');
  }
}

If your site supports both RTL and LTR layouts, you could do something like this:

@layer base {
  :where([dir="rtl"]) select {
    background-position: left theme('spacing.2') center;
    padding-left: theme('spacing.10');
    padding-right: theme('spacing.3');
  }
}

Note the use of :where to keep the specificity low so that you can still override these values with utility classes when needed.

Open to looking at a PR to make this all work automatically but what I've outlined here is what I would recommend in the mean time 👍🏻

Going to close for now since this is the expected behavior (since we don't explicitly support RTL at this time), but hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants