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

Does create-react-app includes a reset css? #2273

Closed
Vadorequest opened this issue May 19, 2017 · 32 comments
Closed

Does create-react-app includes a reset css? #2273

Vadorequest opened this issue May 19, 2017 · 32 comments

Comments

@Vadorequest
Copy link

Vadorequest commented May 19, 2017

I wonder if this tool includes a reset.css (injected dynamically somehow?) (basically to make all websitesbahve the same, regardless of the browser). I'm just curious. If it doesn't, what would you recommend?

Thanks.

@gaearon
Copy link
Contributor

gaearon commented May 20, 2017

Not currently but I think we should. I just don't know what's the best practice these days.

@Timer
Copy link
Contributor

Timer commented May 20, 2017

I'd suggest Normalize.css or Bootstrap's more opinionated Reboot.

@gaearon
Copy link
Contributor

gaearon commented May 20, 2017

I'm cool with whatever most people would be cool with.

@Timer
Copy link
Contributor

Timer commented May 20, 2017

In align with our philosophy, I'd run with normalize. I don't think it's a topic that really needs discussed, its purpose is to fix browsers and normalize them all according to the official spec.
If anything, it'll reduce confusion (which is good!).

I also believe Reboot requires newer browsers, and we support IE 9+, so...

@Vadorequest
Copy link
Author

Okay, thanks!

I think i'm gonna go with https://github.com/necolas/normalize.css

So, a simple install & import should work fine.

  • Run npm install --save normalize.css
  • Add import 'normalize.css'; (in index.js for instance, preferably before everything else)

@gaearon
Copy link
Contributor

gaearon commented May 20, 2017

This sounds good.

I would probably also tweak our default index.css to do just a few more opinionated things like box-sizing: border-box for everything.

@Timer
Copy link
Contributor

Timer commented May 20, 2017

I would probably also tweak our default index.css to do just a few more opinionated things like box-sizing: border-box for everything.

We're pretty much approaching what Reboot does that that point, so it may be more sensible if we add some tweaks (like pixel fallback) and IE9 stuff back from normalize.css.

@gaearon
Copy link
Contributor

gaearon commented May 20, 2017

Mmm. Reboot looks too opinionated to me. Honestly, Normalize + border-box in index.css seems like all I want, but is there a reason it’s not a good way?

@Timer
Copy link
Contributor

Timer commented May 20, 2017

Nope, we can go with it 😄 sorry for my extended rambling.

Do we want to put Normalize into index.css or forcibly include it hidden somewhere?

@gaearon
Copy link
Contributor

gaearon commented May 20, 2017

I would explicitly put it as a default dependency and an explicit import because people might want to replace it with some other reset and it's okay.

Not sure if it's best to import in JS or CSS.

@gaearon gaearon added this to the 1.x milestone May 20, 2017
@luftywiranda13
Copy link
Contributor

luftywiranda13 commented May 23, 2017

@gaearon @Timer

also add this too maybe:

input {
  -webkit-appearance: none;
}

@mlspinylobster
Copy link

I think sanitize.css is also good.
It is the normalize.css + border-box you want.

@ummahusla
Copy link

@mlspinylobster Thanks! Going to try it

@cloud-walker
Copy link

sanitize.css seems a nice improvement (a bit more opinionated) over normalize.css

@cr101
Copy link
Contributor

cr101 commented Jul 8, 2017

Will this override a CSS Framework's own reboot.css?

@FDMatthias
Copy link

Are there any plans to implement this in create-react-app? If not, could I suggest adding something to the user guide (perhaps some simple steps to install normalize.css or sanitize.css manually)?

@armandabric
Copy link

Not sure if it's best to import in JS or CSS.

As this is CSS stuff it seems more natural to import in the CSS.

The only missing feature of CRA is to allow CSS import from the node_modules folder. With this only the documentation should have to be updated to explain how to add a reset in the project

@Timer
Copy link
Contributor

Timer commented Sep 14, 2017

You can import css from node_modules, is something not working for you? Please file an issue!

@armandabric
Copy link

armandabric commented Sep 14, 2017

Ho I should be drunk last time. Now I succeed to import normalize.css from my node_modules:

/* in index.css */
@import '../node_modules/normalize.css/normalize.css';

So as this works, it seems the most important move is to do this import it the base template. I could try a PR if you want

@Timer
Copy link
Contributor

Timer commented Sep 14, 2017

You can also use this in your index.js:

import 'normalize.css/normalize.css';

But sure, a PR would be appreciated!

@PedroFerr
Copy link

Besides reseting BS, you can even mixed up with your own "reset". It works and React respects the order of loading.

// Bootstrap css is @ node-modules, this dir:
import 'bootstrap/dist/css/bootstrap.css';
// Reset everything:
import './reset-css.css';
// Get in 'Normalize.css':
import 'normalize.css/normalize.css'
// And finally import general main css of the entire React App:
import './index.css';

@gaearon gaearon modified the milestones: 1.x, 2.x Jan 14, 2018
@akparhi
Copy link

akparhi commented Jan 22, 2018

@gaearon I don't think a react boilerplate should include CSS reboot/reset. From what I see a lot of frameworks provide reboot(example Material UI v1, Bootstrap). If I'd be using material UI, then I would like to use the included reboot component and not have to deal with removing/overriding the reboot provided by a boilerplate.

TLDR: I believe CSS reset should be provided(as done by some) by the UI components library or by some external library that the user will add. If anything such introduced into create-react-app, it should be optional.

@mrchief
Copy link
Contributor

mrchief commented Jun 7, 2018

Also worth mentioning is postcss-normalize. The biggest selling factors are:

PostCSS Normalize lets you use the parts of normalize.css you need, based on your project’s browserlist.

and

PostCSS Normalize uses the non-opinionated version of normalize.css.

@Timer Timer removed this from the 2.x milestone Nov 2, 2018
@Nothing-Works
Copy link

@Timer is this still going to be added in CRA 2.x?

@Timer
Copy link
Contributor

Timer commented Nov 8, 2018

More than happy to accept a contribution using something like postcss-normalize.

@mrchief
Copy link
Contributor

mrchief commented Nov 8, 2018

I'd like to help but I may need a few pointers. Specifically, is this something that is masked by a flag/option or enabled by default? And if there are any dos and donts that I should be aware of, that'd be helpful as well.

@Fabianopb
Copy link
Contributor

This looks a nice feature to have. So I'd say it's enabled by default, one of the core ideas of CRA is that we avoid flags whenever possible. Most important dos and don'ts can be found in the contribution guidelines.

So @mrchief let me know if you plan to grab this one or not, I've contributed to the SASS loader for CRA2 so this looks straightforward to me and I'd be happy to grab in case you're busy. :)

@mrchief
Copy link
Contributor

mrchief commented Nov 14, 2018

Thanks @Fabianopb for the pointers. Let me take a shot at this if you haven't started already.

@Fabianopb
Copy link
Contributor

No I haven't, please go on!

@mrchief
Copy link
Contributor

mrchief commented Nov 15, 2018

On it!

@stale
Copy link

stale bot commented Dec 15, 2018

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Dec 15, 2018
@stale
Copy link

stale bot commented Dec 20, 2018

This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.

@stale stale bot closed this as completed Dec 20, 2018
@lock lock bot locked and limited conversation to collaborators Jan 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests