React Native Styling: Difference between revisions

From bibbleWiki
Jump to navigation Jump to search
Line 1: Line 1:
=Overview=
=Overview=
==Resources==
Go to https://github.com/danielstern/styling-react-native. Really like Daniel.
==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'''
Line 31: Line 33:
});
});
</syntaxhighlight>
</syntaxhighlight>
=Flex Box=
=Flex Box=
<syntaxhighlight lang="jsx">
<syntaxhighlight lang="jsx">
</syntaxhighlight>
</syntaxhighlight>

Revision as of 13:18, 14 December 2020

Overview

Resources

Go to https://github.com/danielstern/styling-react-native. Really like Daniel.

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
    }
});

Flex Box