Is it better to change native Bootstrap classes or create subclasses and override?

3

In the project I am studying / working on I am making minor adjustments to native Bootstrap classes to meet my needs.

1: Is this really the best practice? Or is it better to create our classes and override bootstrap? Or is there any other best practice for us to customize our projects?

For example, below I created a class to modify a Bootstrap native navbar:

.navperson {
    box-shadow: 2px 2px 8px rgba(0,0,0,0.5);
    color: #ffffff;
    border-top: 2px solid #5bc0de;
    border-bottom: 2px solid #5bc0de;
}

2: In the .html document, first I always need to link bootstrap .css and then custom .css, right? If we apply the bootstrap .css later, it will not overwrite the custom .css properties, right?

3: Does the order of classes change anything?

Ex:

<nav class="navbar navbar-expand-md navbar-light navperson">

Or:

<nav class="navperson navbar-light navbar-expand-md navbar">
    
asked by anonymous 04.10.2017 / 15:45

1 answer

4

Look, I was scratching my finger to send the question to the review queue as "mostly opinion-based." But there is one thing about good and bad practices that is not opinion, it is a fact.

Bootstrap, like the vast majority of large-use libraries, evolves over time. If your system is widely used, it will tend to evolve as well.

If you change the Bootstrap native classes or any other library, you will be shooting yourself in the c ... er, foot. Every time you upgrade your system, if you have a new version of the libraries that you have tampered with, you will have a trilemma:

  • Discard any changes you've made, or;
  • Get stuck with an outdated version of the library, or;
  • Make a merge of what you did with the new version of the library. In general you only see people doing this when you use astral projection to visit the lower levels of hell.

If you use subclasses and overrides, you will still have this problem, but the impact will be orders of magnitude lower. Depending on how you do this, the impact may be insignificant. In general, the greater your skill and reuse experience, the better.

The very ideal is not to try to reinvent the wheel, and re-design those libraries only if your visual identity really depends on it.

    
04.10.2017 / 16:08