React Native Styling: Difference between revisions

From bibbleWiki
Jump to navigation Jump to search
Line 2: Line 2:
==Stylesheet.create()==
==Stylesheet.create()==
Camel Case is used and an object created. There are no px suffixes for pixel values. Should work on all devices. The names do not necessary align with Android or IoS name. '''Only works on React components and not standard tags like div'''
Camel Case is used and an object created. There are no px suffixes for pixel values. Should work on all devices. The names do not necessary align with Android or IoS name. '''Only works on React components and not standard tags like div'''
<syntaxhighlight code="jsx">
<syntaxhighlight lang="jsx">
const styles = Stylesheet.create({
const styles = Stylesheet.create({
   container: {
   container: {
Line 12: Line 12:
<br>
<br>
'''The snippet for this is rnss'''
'''The snippet for this is rnss'''
==Fixed Dimension==
==Fixed Dimension==
A brief example of fixed dimensions shows how to build a POC for a specified device. Whilst no good for release it is a lot quicker to build for one offs.
A brief example of fixed dimensions shows how to build a POC for a specified device. Whilst no good for release it is a lot quicker to build for one offs.

Revision as of 13:04, 14 December 2020

Overview

Stylesheet.create()

Camel Case is used and an object created. There are no px suffixes for pixel values. Should work on all devices. The names do not necessary align with Android or IoS name. Only works on React components and not standard tags like div

const styles = Stylesheet.create({
   container: {
      backgroundColor: "white",
      height: 470.
   }
})


The snippet for this is rnss

Fixed Dimension

A brief example of fixed dimensions shows how to build a POC for a specified device. Whilst no good for release it is a lot quicker to build for one offs.

Images

Images need either a width of a height to show in react native. Without no image is shown. In the course they used this. I do like the hairlineWidth

...
export const Logo = () => (
    <Image source={img} style={styles.logo} />
)

const styles = StyleSheet.create({
    logo: {
        height: 110,
        borderBottomColor: 'darksteelblue',
        borderBottomWidth: StyleSheet.hairlineWidth
    }
});