react-select icon indicating copy to clipboard operation
react-select copied to clipboard

Styling is not applied to the select list.

Open thirdknife opened this issue 11 years ago • 17 comments

After installing through npm when I add this snippet

<Select
     name="filter-category"
     value="one"
     options={options}
     onChange={logChange}
/>

I get a list but the styling is totally off. Can you help what's going wrong here. screen shot 2015-11-23 at 6 40 43 pm

thirdknife avatar Nov 23 '15 13:11 thirdknife

Are you importing the component like import Select from 'react-select'; and using a bundler like Webpack? Then you have to import the CSS explicitly: import 'react-select/dist/react-select.css';

bzums avatar Nov 23 '15 15:11 bzums

Otherwise this maybe interesting: https://github.com/JedWatson/react-select/issues/602

bzums avatar Nov 23 '15 15:11 bzums

There was css loader missing with the https://github.com/christianalfoni/webpack-express-boilerplate webpack configuration

    {
      test: /\.css$/,
      loader: 'style!css?modules&localIdentName=[name]---[local]---[hash:base64:5]',
      include: path.join(__dirname, 'app')
    },
    {
      test: /\.css$/,
      loader: 'style!css',
      include: path.join(__dirname, 'node_modules')
    }

Shouldn't it be loading by default. Is this an issue with the module it self or just the config?

thirdknife avatar Nov 23 '15 18:11 thirdknife

Mhh maybe the following line has something to do with it: https://github.com/JedWatson/react-select/blob/master/package.json#L6

Because this css file is not existing, currently?!

BTW @thirdknife is it working for you with the given loaders?

bzums avatar Nov 24 '15 08:11 bzums

@bzums yes it's working for me with the loaders. I am closing this issue now.

thirdknife avatar Nov 24 '15 12:11 thirdknife

@thirdknife can you elaborate on why a loader is necessary? I'm having the same issue, loading the style manually works as a solution, but I'd prefer not to!

mattparrilla avatar Dec 04 '15 21:12 mattparrilla

@mattparrilla it's because if you read https://github.com/JedWatson/react-select/blob/master/package.json line 6 it says "style": "dist/default.css", but infact the dist folder does not contain default.css

thirdknife avatar Dec 04 '15 22:12 thirdknife

@bzums

I import the component like import Select from 'react-select'; and using a bundler like Webpack. And every time I have to add import 'react-select/dist/react-select.css';?

Is there another simple way?

clinyong avatar Mar 08 '16 04:03 clinyong

I''m using NPM and the CSS is missing - any ideas?

mrconnormurphy avatar Apr 06 '16 14:04 mrconnormurphy

@mrconnormurphy you currently need to make sure you import the css - either the built .css file from /dist or you can include the .less or .sass versions into your own less or sass files (or import them directly with webpack loaders)

I'm thinking for simplicity of use, we might implement inline styles as an option, but that won't be for 1.0

JedWatson avatar Apr 07 '16 14:04 JedWatson

in your js component fil just import the scss import 'react-select/scss/default.scss'

then in the webpack.config module loaders make sure to remove exclude: /node_modules/ beacause you will load the scss from that folder

ciocan avatar Apr 07 '16 15:04 ciocan

@JedWatson Thanks Jed - appreciate it

I directly linked the CSS via my index.html file
<link rel="stylesheet" type="text/css" href="node_modules/react-select/dist/react-select.css">

This seemed to fix the CSS issue.

mrconnormurphy avatar Apr 08 '16 07:04 mrconnormurphy

I had to copy the css from node_modules/react-select/dist/react-select.css into my own stylesheet to fix the css issue, and from there I can override some styles to fit my design.

bntzio avatar Sep 12 '16 08:09 bntzio

How to fix it https://github.com/JedWatson/react-select/issues/602#issuecomment-254835096

SVITY avatar Oct 19 '16 14:10 SVITY

I am still not able to fix the issue after following the above solutions. I am not using webpack. Steps i) Importing react-select import Select from "react-select"; ii) Using it in the component Select name="filter-category" value="one" options={options} onChange={logChange}

iii) Placed react-select.css in the same directory as above component. And imported it in the component. import "./react-select.css"; iv) When i npm run the client i am seeing the drop down in same format as the top image in this issue thread.

braj065 avatar Jul 17 '18 11:07 braj065

@JedWatson node_modules/react-select/dist/react-select.css this file does not exist in my node_modules directory. How to fix it? My react-select package version is 5.7.4

adrianomic avatar Jul 20 '23 18:07 adrianomic

@JedWatson node_modules/react-select/dist/react-select.css this file does not exist in my node_modules directory. How to fix it? My react-select package version is 5.7.4

https://github.com/JedWatson/react-select/issues/5710#issuecomment-1913643129

honia19 avatar Jan 28 '24 16:01 honia19