Border deprecated or not?


#1

Hi!

For my app I use the Border element quite happily but I always get the console.log telling that Border is deprecated. However, the most recent github issue on this (https://github.com/NativeScript/NativeScript/pull/2485) suggests that the Border wasn’t deprecated after all. I curious whether the Border is deprecated or not.

Thanks,

Bronco


#2

It’s deprecated according to the documentation since a border can be configured with CSS nowadays.


#3

Well, the mentioned issue (2485) suggests the deprecation is withdrawn and that there is a solid use case for Border to remain. There is such a thing as documentation errors as well, so I want to know what the status is on this.


#4

Hey @bfv @NordlingArt

Indeed the border module is still available at this very moment however as discussed in our issue the only reason to keep it alive is simply not to break already done projects.
However, I would strongly discourage the usage of this module for settings borders with CSS.
There are a couple of reasons you might want to prefer CSS styling instead of the border module.
IN the lines below I will cover most of them:

  • Performance
    Using the Borde module is creating additional UI elements which are making your layouts “heavier.”

  • Code reuse
    Using CSS will allow you to create a common style border and simply reuse this style where needed.
    Here are the options you are receiving with the CSS border styling

border-color	borderColor	Sets a border color to the matched views.
border-width	borderWidth	Sets a border width to the matched view’s.
border-radius	borderRadius	Sets a border radius to the matched view’s.
  • Easier per side applying of borders with CSS
    Now with the CSS syntax, you can already apply border only per selected sides of your element
    e.g.
.btn {
    border-width: 5 10 15 20;
    border-color: red;
}

So the argument in https://github.com/NativeScript/NativeScript/pull/2485#issuecomment-234403342 is no longer valid.

All that said I think there are only advantages in using CSS borders.


#5

Hi @NickIliev,

Thanks for the elaborate reply and clarifying matters. CSS it is.

Cheers,

Bronco