CSS Properties define how you style each view. This page documents the CSS properties available for native iOS and Android views.
Navigation and Action Bars
Navigation bars can be styled like any other view.
To simplify cross platform development, navbar matches both iOS UINavigationBars and Android ActionBars.

navbar{
background-image:url('texture.png')
}
iOS7 Status Bar
On iOS7, the status bar is styled like the navigation bar:
For nativeCSS to automatically select the appropriate status bar, you’ll need to set View controller-based status bar appearance to NO in your Info.plist:
Navigation Title
Styling the title view is slightly different on iOS and Android.

navbar, actionbar label{
color:red;
font-family:'Times New Roman';
font-size:10px
}
Navigation Buttons
Styling the navigation button is also slightly different. For iOS use the nth-of-type selector and for Android use the menu view id.

navbar{
background-image:url('texture.png')
}
navbar button:nth-of-type(2), navbar #menu_settings{
background:-linear-gradient(#98ba40, #a6c250 35%, #618926)
}
iOS Back Buttons

navbar #backButton{
background: url('left.png') 2px middle 10px 15px no-repeat;
}

navbar #backButton{
background: url('left.png') 2px middle 10px 15px no-repeat,linear-gradient(top,hsl(106,13,74),hsl(124,50,50) 50%,hsl(125,83,39) 50%,hsl(129,85,33));
border:1px solid rgb(43,43,43);
border-radius:5px;
}
Tables and Lists

#table{
background-color:blue
}
#table > view{
background-color:blue
}
#table > view:nth-child(odd){
background-color:red
}

For iOS, find your table datasource, and add our import
#import "UITableViewCell+NativeCSS.h"
Next add this line to tableView:cellForRowAtIndexPath:indexPath:
[cell refreshCSSStylingWithTableView:tableView cellForRowAtIndexPath:indexPath];
For Android, find your list adapter, and add this import
import com.nativecss.NativeCSS;
Next add this line to getView(int position, View convertView, ViewGroup parent)
NativeCSS.refreshCSSStyling(position,convertView,parent);
Learn more about styling tables in our tutorials
Tab Bars
tabbar{
background:-linear-gradient(#98ba40, #a6c250 35%, #618926)
}

tabbarbutton > label{
color:white;
font-family:courier;
width:100%;
text-align:center
}

tabbar{
background:linear-gradient(grey,white)
} label{
color:black;
font-family:courier;
width:100%;
text-align:center
} tabbarbutton{
background:url('star_w.png') no-repeat center 2px 25px 25px
} tabbarbutton:nth-child(2){
background:url('person.png')
} tabbarbutton:nth-child(3){
background:url('settings.png')
}
Segmented Controls
Style UISegmentedControls with both a default state and an active state:
UISegmentedControl{
background: white,linear-gradient(rgba(0,0,0,0.2),rgba(0,0,0,0));
border-radius:10px;
border:1px solid rgb(167,167,167)
}
UISegmentedControl:active{
background: red,linear-gradient(rgba(0,0,0,0.1),rgba(0,0,0,0.3) 80%,rgba(0,0,0,0.6))
}
UISegmentedControl{
background: white,linear-gradient(rgba(0,0,0,0.2),rgba(0,0,0,0));
border-radius:10px;
border:1px solid rgb(167,167,167)
}
UISegmentedControl:active{
background: url('wood.jpg')
}
Animations
@keyframes shrink{
to {
margin:auto;
width:0%
}
}
img{
animation-name: shrink;
animation-duration:0.3s
}
@keyframes fade{
from {
opacity:1
} to {
opacity:0
}
}
img{
animation-name: fade;
animation-duration:0.3s
}
- margin
- left
- right
- top
- bottom
- width
- height
- opacity
Filters
Style any view with iOS7 standard frosting.

toolbar{filter:frosting}
Or add a background color tint:

toolbar{
filter:frosting;
background:rgba(196,233,251,0.8)
}
Background
Background is a shorthand for all background styling properties. For more information on background images see background-image below.

img{
background: grey url('clock.png') center middle no-repeat
}

img{
background: url('clock.png') center middle no-repeat, url('texture.png')
}

img{
background: url('clock.png') center middle no-repeat, linear-gradient(rgba(0,0,0,0.9),transparent), lightgrey
}

img{
background: url('clock.png') center middle no-repeat, linear-gradient(rgba(0,0,0,0.9),transparent), url('texture.png')
}
Loading from iOS asset bundles
img{
background: grey url('Media.bundle/clock.png') center middle no-repeat
}
background-color


label{
background-color:yellow
}


label{
background-color:#00ff00
}


label{
background-color:rgb(255,0,255)
}


label{
background-color:rgba(255,0,255,0.5)
}


label#label{
background-color:hsl(180,50%,75%)
}


label#label{
background-color:hsla(180,65%,65%,0.2)
}
background-image, background-position, background-size, background-repeat
Background images can be loaded from inside the app or remotely from the internet.


#shadedView{
background-image: url(tick.png);
background-position:0px 0px;
background-size:20px 20px;
background-repeat:no-repeat
}
The image tick.png needs to be in the app for this to work. In iOS the image just need to be included in the app, in android this means specifically the drawable folder for images and assets folder for fonts.
Remote Images


label#label{
background-image:url('http://localhost/assets/tests/icons/clock.png');
background-position:80px 0px;
background-size:20px 20px;
background-repeat:no-repeat
}
Images downloaded from the internet can also be loaded using a relative path.


label#label{
background-image:url('/assets/tests/icons/clock.png');
background-position:80px 0px;
background-size:20px 20px;
background-repeat:no-repeat
}
You’ll also need to tell nativeCSS what remote host URL to use:
NativeCSS.styleWithCSS(css, new URL("https://nativecss.com"));
[UIApplication
styleWithCSSString:css
withRemoteHost:[NSURL URLWithString:@"https://nativecss.com"]
];
Border


imageview{
border:5px solid silver
}

border-bottom


imageview{
border:5px solid silver;
border-bottom:10px solid gold
}
border-bottom-color, border-bottom-width


imageview{
border:5px solid silver;
border-bottom-color:gold;
border-bottom-width:10px
}
border-left


imageview{
border:5px solid silver;
border-left:10px solid gold
}
border-left-color,border-left-width


imageview{
border:5px solid silver;
border-left-color:gold;
border-left-width:10px
}
border-right


imageview{
border:5px solid silver;
border-right:10px solid gold
}
border-right-color,border-right-width


imageview{
border:5px solid silver;
border-right-color:gold;
border-right-width:10px
}
border-top


imageview{
border:5px solid silver;
border-top:10px solid gold
}
border-top-color,border-top-width


imageview{
border:5px solid silver;
border-top-color:gold;
border-top-width:10px
}
border-radius


imageview{border-radius:10px}
box-shadow


imageview{
box-shadow: 10px 10px 5px #888888
}


imageview{
box-shadow: -10px 10px 5px 5px #888888
}

Layout
Autolayout in iOS
Autolayout is supported, but nativeCSS removes any conflicting contraints. This may lead to styling errors where both Autolayout and CSS styling are intertwined, where the CSS Styling will always have highest priority.
Linear Layout in Android
Android’s LinearLayout is only partially supported. For advanced styling, we’d recommend using Android’s FrameLayouts.
height


imageview{height:40px}


imageview{height:30%}
width


imageview{width:40px}


imageview{width:30%}
Font
font-family


label{
font-family:Times New Roman
}
Note: Android and iOS
default fonts are different. We recommend using font-face for cross platform development.


@font-face{
font-family: SourceSans;
src: url('SourceSansPro-Bold.otf');
font-weight:bold
} #label{
font-family:"SourceSans";
font-style:normal;
font-weight:bold
}


@font-face{
font-family: SourceSans;
src: url('http://localhost/assets/fonts/SourceSansPro-Bold.otf');
font-weight:bold
} #label{
font-family:"SourceSans";
font-style:normal;
font-weight:bold
}
font-size


label{font-size:12px}


label{font-size:12pt}

font-style


label{font-style:bold}
Note: Android and iOS
default fonts are different. We recommend adding any required font
files to the app.
Margin

#subViewLabel{
margin:auto;
width:120px
}
This is correct, but our tests find it hard to talk about it.
margin-left


label{
border:5px solid silver;
margin-left:10px
}
margin-top


label{
border:5px solid silver;
margin-top:10px
}
Padding


label{
border:5px solid silver;
padding:10px
}
padding-bottom


label{
border:5px solid silver;
padding-bottom:10px
}
padding-left


label{
border:5px solid silver;
padding-left:10px
}
padding-right


label{
border:5px solid silver;
padding-right:10px
}
padding-top


label{
border:5px solid silver;
padding-top:10px
}
Text
color


label{color:gold}
text-align


label{text-align:right}
text-transform


label{
text-transform:uppercase
}


label{
text-transform:lowercase
}


label{
text-transform:capitalize
}
text-overflow


label{
text:lots of words in label ipsum lorem;
text-overflow: ellipsis
}


label{
text:lots of words in label ipsum lorem;
text-overflow: clip
}
text-shadow


label{
text-shadow:1px 1px grey
}


label{
text-shadow:-1px -1px black
}


label{
text-shadow:-1px 1px 1 black
}
The above tables are based on the fine work of w3schools.com
Cross Platform
Sometimes you only need to style an Android or iOS view, without changing the other.
Simply prefix any properties with -ios- or -android- to style either iOS or Android only.


img{
-ios-border:2px solid gold;
-android-border:2px solid silver;
padding:5px
}
OS Versions
iOS7 has a radically different UI to previous iOS versions and your app style should reflect this.
Simply prefix any properties with -min-ios7- to target iOS 7.0 and above or -max-ios6- for earlier iOS versions.

button{
-min-ios7-background:gold;
-max-ios6-background:silver;
-min-android4.2-background:gold;
-max-android4.2-background:silver
}