Getting started

What follows within the Fundamentals section of this documentation is a tour of the most important aspects of React Native Picasso. It should cover enough for you to know how to build your own design system, and give you the background that you need to dive deeper into the more advanced parts of Picasso.

Installation

Install the required packages in your React Native project:

yarn add react-native-picasso

Usage

Picasso ships with a set of drop in replacements components. You can import the following three components : View, SafeAreaView, Text

import { View, Text, SafeAreaView } from 'react-native-picasso'

All those components are sharing the same API as their usual react-native counter party. But they have an aditionnal prop called className. The className property consists of a string of pre-defined classes separated by a space.

Classes are constructed the following way : {property}-{value}

Using this string, you can describe the apparence of your components.

For example the following className="ml-md p-lg" would be translated to margin-left: medium; padding: large.

All the values are declared in a defaultTheme variable. Which is :

{
colors: {
background: '#eeeeee',
primary: '#00B386',
secondary: '#dedede',
},
textColors: {
primary: '#333333',
secondary: '#666666',
white: '#ffffff',
},
font: {
family: 'Helvetica',
sizes: {
sm: 12,
md: 16,
lg: 24,
xl: 32,
xxl: 40,
},
weights: {
light: '100',
normal: 'normal',
bold: 'bold',
extrabold: '800',
},
},
elevated: {
shadowColor: '#000000',
shadowOffset: { width: 0, height: 5 },
shadowOpacity: 0.2,
shadowRadius: 3,
elevation: 5,
},
radius: {
sm: 5,
md: 10,
lg: 20,
xl: 40,
round: 1000,
},
spacing: {
sm: 8,
md: 16,
lg: 24,
xl: 32,
xxl: 40,
},
}

If we take the previous example, margin and padding are using the "spacing" values. So the final result of className="ml-md p-lg" would be :

{
marginLeft: 16,
padding: 24
}

Here is a table of all the possible properties and values you can use inside a className.

Base (Available for all components)

PropertyPossible valuesDescription
psm, md, lg, xl, xxlpadding
plsm, md, lg, xl, xxlpaddingLeft
prsm, md, lg, xl, xxlpaddingRight
ptsm, md, lg, xl, xxlpaddingTop
pbsm, md, lg, xl, xxlpaddingBottom
pxsm, md, lg, xl, xxlpaddingHorizontal
pysm, md, lg, xl, xxlpaddingVertical
------------------------------------------------
msm, md, lg, xl, xxlmargin
mlsm, md, lg, xl, xxlmarginLeft
mrsm, md, lg, xl, xxlmarginRight
mtsm, md, lg, xl, xxlmarginTop
mbsm, md, lg, xl, xxlmarginBottom
mxsm, md, lg, xl, xxlmarginHorizontal
mysm, md, lg, xl, xxlmarginVertical
------------------------------------------------
flexrow, columnflexDirection
flexany numberflex: value
alignselfcenter, start, end, stretch, baselinealignSelf

View specific

PropertyPossible valuesDescription
elevatedno valueAdds a drop shadow to your view
radiussm, md, lg, xlborderRadius
radiustlsm, md, lg, xlborderTopLeftRadius
radiustrsm, md, lg, xlborderTopRightRadius
radiusblsm, md, lg, xlborderBottomLeftRadius
radiusbrsm, md, lg, xlborderBottomRightRadius
bgprimary, secondary, backgroundbackgroundColor
justifycontentcenter, start, end, around, between, evenlyjustifyContent
alignitemscenter, start, end, stretch, baselinealignItems
bordercolorprimary, secondary, background, borderborderColor
bany numberborderWidth
brany numberborderRightWidth
blany numberborderLeftWidth
btany numberborderTopWidth
bbany numberborderBottomWidth

Text specific

PropertyPossible valuesDescription
weightlight, normal, bold, extraboldfontWeight
aligncenter, left, right, justifytextAlign
colorprimary, secondary, whitecolor
sizesm, md, lg, xl, xxlfontSize

Each value of each property is mapped to a specific section of the theme.

Examples

<View className="p-md radius-md elevated">{/* Content */}<View>

Translates into

<View style={{
padding: 16,
borderRadius: 10,
shadowColor: '#000000',
shadowOffset: { width: 0, height: 5 },
shadowOpacity: 0.2,
shadowRadius: 3,
elevation: 5
}}>
{/* Content */}
<View>