Skip to content
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

Unable to style input element with the new classNames API in 5.7 #5538

Open
Slessi opened this issue Jan 14, 2023 · 5 comments
Open

Unable to style input element with the new classNames API in 5.7 #5538

Slessi opened this issue Jan 14, 2023 · 5 comments
Assignees
Labels
issue/bug-unconfirmed Issues that describe a bug that hasn't been confirmed by a maintainer yet

Comments

@Slessi
Copy link

Slessi commented Jan 14, 2023

In PR #5457 the classNames API was added - but I think the input one is not correct?

Previously, the below styling for an "input" would target the <input /> element:

.re-select__input {
  /* whatever */
}
<Select classNamePrefix="re-select" />

However the below code instead targets the input-container div around it:

<Select classNames={{ input: () => 'whatever' }} />

I think its a mistake in here? https://github.com/JedWatson/react-select/pull/5457/files#diff-07753302222b58b652fb23698902955708f7f700fdeecf15980423588766fef4R107-R112

Possible you need to expose input and inputContainer separately, not sure how to style the input as before with classNames

@Slessi Slessi added the issue/bug-unconfirmed Issues that describe a bug that hasn't been confirmed by a maintainer yet label Jan 14, 2023
@Slessi Slessi changed the title <title> Unable to style input element with the new classNames API in 5.7 Jan 14, 2023
@NicholasCanova
Copy link

NicholasCanova commented Feb 8, 2023

@lukebennett88 - any update on this one? I'm having an issue with text being hidden in the input element, where adjusting the input width would resolve the issue. But I have no way to change the input's styles per the main issue of this posting.

@nderkim
Copy link
Collaborator

nderkim commented Feb 15, 2023

The classNames prop actually follows the logic of the styles prop, and the styles prop input actually gets applied to the input-container, which is why the same thing is happening for the classNames API. I'm not sure if this was intentional, but changing it to apply to input instead of input-container will break for alot of people who are using the styles prop 🤔

@M-Faheem1
Copy link

I was facing the same issue of styling input field and other elements been hidden in input field. Firstly i just rename the classes using props like this:
className='react-select-container'
classNamePrefix='react-select'

and in Inspect mode got the class name for input field and other elements in it.
And further if you are concerned about to style options list menu which goes hidden when you try to inspect or input`s other elements in it. For that, firstly target react-input-container class which can be default .react-select__input-container if you re-name the classes using above props and set it to display: none; after that you will be able to inspect all the elements in options menu and input field and after completing your styling you can remove the property of display: none; if you want that search field visible.

@carstenblt
Copy link

Can confirm, input doesn't style the input element.

@LeonDWong
Copy link

Same issue here. Get puzzled by debugging style in input, but find out all styles is applying to input-container which is div element.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue/bug-unconfirmed Issues that describe a bug that hasn't been confirmed by a maintainer yet
Projects
None yet
Development

No branches or pull requests

7 participants