Nativescript: Allow borders to be applied on a per-side basis in CSS

Created on 30 Sep 2015  Â·  58Comments  Â·  Source: NativeScript/NativeScript

I'm finding that I frequently need to put a border on one side of a UI component, but NativeScript currently does not support this. I'm requesting that the following CSS properties be added:

  • border-top-width
  • border-top-color
  • border-right-width
  • border-right-color
  • border-bottom-width
  • border-bottom-color
  • border-left-width
  • border-left-color

To be consistent with CSS, I would also like the border-width and border-color shorthands to work like they do in CSS.

screen shot 2015-09-30 at 8 17 47 am

Update: You can vote for this feature at https://nativescript.ideas.aha.io/ideas/NS-I-110.

Thanks.

css done feature high ux

Most helpful comment

screenshot_20160917-161341
simulator screen shot sep 17 2016 4 14 45 pm

All 58 comments

Yes please :+1:

:+1:

:+1:

:+1:

@tjvantoll do you have any workaround now?

:+1:

So how do we set a border to a specific side right now?

What I’ve been doing is something like <stack-layout style="height: 2; border-color: red; border-width: 2;"></stack-layout>, which is definitely hacky, but it works until per-side borders are truly supported.

Oh haha okay, thanks.

It feature is just vital! :+1:

+1

+1

+1

+1

So how do we set a border to a specific side right now? Like the TabView does for the border-bottom?

+1

+1

+5

+1

+1

+1

+1

+1

+1

Common, lets tag this with "high" we all need it, height:1 StackLayout is suuuuper bloaty and hacky

:+1:

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

Guys, vote here, please: https://nativescript.ideas.aha.io/ideas/NS-I-110

@tjvantoll would you mind add this link to your description?

great idea @Leo.
done!
On May 11, 2016 5:18 AM, "Leo Caseiro" [email protected] wrote:

Guys, vote here, please: https://nativescript.ideas.aha.io/ideas/NS-I-110

—
You are receiving this because you commented.
Reply to this email directly or view it on GitHub
https://github.com/NativeScript/NativeScript/issues/859#issuecomment-218351516

@leocaseiro: @tjvantoll would you mind add this link to your description?

Done!

And just an fyi to everyone watching here, per-side borders are pretty easy to do on Android, but a complete pain on iOS—which is why this hasn’t been implemented in the modules yet. Getting per-side borders right on iOS is a big engineering challenge, and it’s not as simple as adding a few properties into a list. (Side note: I took a stab at implementing border-bottom on an iOS UITextField and failed horribly myself.) That being said, we realize there’s a lot of demand here so we do want to tackle this. If you want to see this implemented add your vote to help us prioritize.

+1

👍

👍

+1

probably a dependency to #1763

Will it require :first-child and :last-child pseudo class selectors after it?

+1

+1

@tjvantoll iOS has sufficient APIs to draw it.

FWIW, I just use a background image for what i've needed so far ( a single line underneath an element)

+1

+1

https://github.com/NativeScript/NativeScript/pull/2743 adds basic support for non-uniform borders.

Current limitations are:

  • Different border radii on the four corners are not yet supported
  • Border radius is supported only when the border width and color is uniform on all four sides.
  • Images on iOS will still render behind the border as they always have, until a fix is provided.

screenshot_20160917-161341
simulator screen shot sep 17 2016 4 14 45 pm

... So happy right now

:neckbeard:

Awesome!!!

Outstanding issues

  • [ ] Support uniform and non-uniform border radii on non-uniform border colors and/or widths.
  • [ ] Some iOS components such as Image, HtmlView and ListView will render behind the borders. Quick workaround is to place the component inside one of our Layouts and set the borders on the Layout instead.
  • [ ] iOS ScrollView cannot render non-uniform borders nicely with the current approach of adding for child layers to the UIView in order to draw the borders. When scrolling starts these 4 layers fly all around the place.
  • [ ] Android ScrollView draws no borders at all.

NOTE: Progress, Slider, Switch and SearchBar do not render borders by design.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings