1.4.69 • Published 4 months ago

react-native-boxes v1.4.69

Weekly downloads
-
License
ISC
Repository
github
Last release
4 months ago

React Native Boxes

Android Web iOS

A simple to use react library that does all the UI heavy lifting for you so that you can focus on value and not code !

Out-of-the box comes with:

  • Themes
  • Layouts (Cards, Vertical, Horizontal, Centered etc.)
  • Texts (Title, Subtitle, Text, Caption etc.)
  • Buttons (Simple, Transparent, Loading etc.)
  • Images and Icons (Icons, Avatars, Images etc.)
  • Font (Specify Regular, Styled and Bold fonts)
  • Bars (Toolbars, Bottom nav bars etc.)
  • Modals (Dialogboxes, Selection bottomsheet, Horizontal selection etc.)
  • Expand box (Animated)
  • Lists (Simple data list)
  • Webview (In app web browser)
  • Internationalization (I18n)
  • Analytics (Clicks, Impression tracking)

Install

npm install react-native-boxes

Dependencies

Make sure you have following dependencies installed. The versions can be any satisfying version but must not have any breaking changes.

    "@expo/vector-icons": "^13.0.0",
    "react": "^18.2.0",
    "@react-native-async-storage/async-storage": "1.23.1",
    "react-native": "^0.73.6",
    "react-native-safe-area-context": "^4.9.0",
    "react-native-gesture-handler":"~2.14.0"

Usage

At the root of your app you must add a theme context and thats it! You are good to go.

import { Colors, DarkColors, Theme } from 'react-native-boxes';
import { GestureHandlerRootView } from 'react-native-gesture-handler';

export default function App(){ 
    const colorScheme = 'dark'
    const theme = new Theme('my-app', colorScheme === 'dark' ? DarkColors : Colors);
    return (
        <ThemeContext.Provider value={theme} >
            <GestureHandlerRootView> 
                <WatchlistPage />
            </GestureHandlerRootView>
        </ThemeContext.Provider>
    )
}

Optional: If you are also gonna use bottomsheets, Add GestureHandlerRootView

Components

Themes

Dark colors and Light colors come out of the box.

Dark Colors

image

Light Colors

image

You can also customize sizes, dimensions etc, but it is not recommended.

const theme = new Theme(
    appname = '',
    colors  ,
    dimens ,
    fonts  ,
    styles , 
)
    

Layouts

VPage

Your root tag for pages. Consists of vertical alignment and some basic padding.

image

Center

image

<Center>
    <Title>Watchlist</Title>
    <Caption>Coming soon  </Caption>
</Center>

HBox

image

Texts

image

Images

Avatars

image

  • With icon
  • With image url
  • With text
<Avatar iconName='user' />
<Avatar iconUrl='https://avatars.githubusercontent.com/u/16799797?v=4' />
<Avatar iconText='SN' />
      

Icons

Support for Fontawesome icon names from https://icons.expo.fyi/

image

Buttons

image

image

<LoadingButton loading={loading} text='Loading Button' onPress={() => {
    setLoading((prev) => !prev)
  }} />

ezgif-451f0321da765b

Bottombar

image

Expand

Recording 2025-03-01 201906

Toolbars

Simple Toolbar

image

Transparent Center Toolbar

image

Toolbar with buttons

image

Divider

image

Modals

Bottomsheet on mobile

mobile sheet

  <BottomSheet title="Bottomsheet About Watchlists" visible={showDialog} onDismiss={() => setShowDialog(false)}>
    <TextView>
      This is a simple dialog that can be used to show more information to the user. It is a bottom sheet that can host any content.
    </TextView>
    <HBox />
    <TextView>
      Watchlists are a great way to keep track of your favorite stocks. You can add stocks to your watchlist and see their performance. You can also add alerts to get notified when a stock reaches a certain price.
    </TextView>
    <TertiaryButtonView text='Goto Watchlist' onPress={() => setShowDialog(false)} />
  </BottomSheet>
  

Bottomsheet on Desktop (web)

desktop sheet

Web view

Opens a webview on native and a iframe on Web

<WebBrowserView url='https://www.google.com' title='Google'/>

Internationalization

Install your favorite js library.

locale

import { I18n } from 'i18n-js';

const I18nProvider = new I18n({
  en: {
    watchlist: {
      hello: 'Hello!'
    }
  },
  hi: {
    watchlist: {
      hello: 'नमस्ते !'
    }
  },
  hinglish: {
    watchlist: {
      hello: 'Namaste !'
    }
  },
  es: {
    watchlist: {
      hello: 'Hola!'
    }
  }
});
I18nProvider.missingBehavior = "guess";


export default function App(){
    const [locale, setLocale] = useState('en')
    I18nProvider.locale = locale
    const theme = new Theme('appname', colorScheme === 'dark' ? DarkColors : Colors);
    theme.i18n = I18nProvider
    
      
    return (
        <ThemeContext.Provider value={theme} >
        <Center>
              <Title>watchlist.hello</Title>
            </Center>
            <Center>
              <HBox>
                <TransparentButton text='English' onPress={() => {
                  setLocale('en')
                }} />
                <TransparentButton text='Hindi' onPress={() => {
                  setLocale('hi')
    
                }} />
              </HBox>
              <HBox>
                <TransparentButton text='Hinglish' onPress={() => {
                  setLocale('hinglish')
    
                }} />
                <TransparentButton text='Spanish' onPress={() => {
                  setLocale('es')
    
                }} />
              </HBox>
        </Center>
     </ThemeContext.Provider>
    )
 }

Analytics

If you wanna track the users clicks and impressions on each component, just add a onTrack hook to your theme.

action : TrackingActionType = click | view | navigate
view : TrackingViewType = button | dropdown...
text : The text related to the component if present
extra : Depending on component, some contextual info. For e.g. the WebView impression gives {url, title} extra
const theme = new Theme('appname', DarkColors);  
theme.onTrack = (action, view, text, extras) => {
    myTracker.track(`${action}-${text}-${text}`, extras)
}
1.4.60

6 months ago

1.4.62

6 months ago

1.4.61

6 months ago

1.4.64

5 months ago

1.4.63

5 months ago

1.4.66

5 months ago

1.4.65

5 months ago

1.4.68

5 months ago

1.4.67

5 months ago

1.4.69

4 months ago

1.4.51

8 months ago

1.4.50

8 months ago

1.4.53

8 months ago

1.4.52

8 months ago

1.4.55

8 months ago

1.4.54

8 months ago

1.4.57

8 months ago

1.4.56

8 months ago

1.4.59

6 months ago

1.4.58

8 months ago

1.4.31

11 months ago

1.4.30

11 months ago

1.4.33

11 months ago

1.4.32

11 months ago

1.4.35

11 months ago

1.4.34

11 months ago

1.4.37

11 months ago

1.4.36

11 months ago

1.4.39

11 months ago

1.4.38

11 months ago

1.4.40

11 months ago

1.4.42

10 months ago

1.4.41

10 months ago

1.4.44

9 months ago

1.4.43

9 months ago

1.4.46

9 months ago

1.4.45

9 months ago

1.4.48

9 months ago

1.4.47

9 months ago

1.4.20

12 months ago

1.4.22

12 months ago

1.4.21

12 months ago

1.4.24

11 months ago

1.4.23

12 months ago

1.4.26

11 months ago

1.4.25

11 months ago

1.4.28

11 months ago

1.4.27

11 months ago

1.4.29

11 months ago

1.3.31

1 year ago

1.3.32

1 year ago

1.3.30

1 year ago

1.4.11

1 year ago

1.4.10

1 year ago

1.4.13

1 year ago

1.4.12

1 year ago

1.4.15

1 year ago

1.4.14

1 year ago

1.4.17

1 year ago

1.4.16

1 year ago

1.4.19

12 months ago

1.4.18

12 months ago

1.4.6

1 year ago

1.4.5

1 year ago

1.4.4

1 year ago

1.4.3

1 year ago

1.4.2

1 year ago

1.4.1

1 year ago

1.3.28

1 year ago

1.3.29

1 year ago

1.3.27

1 year ago

1.4.9

1 year ago

1.4.8

1 year ago

1.4.7

1 year ago

1.3.25

1 year ago

1.3.26

1 year ago

1.3.17

1 year ago

1.3.18

1 year ago

1.3.19

1 year ago

1.3.20

1 year ago

1.3.24

1 year ago

1.3.22

1 year ago

1.3.23

1 year ago

1.3.16

1 year ago

1.3.14

1 year ago

1.3.15

1 year ago

1.3.13

1 year ago

1.3.10

1 year ago

1.3.11

1 year ago

1.3.12

1 year ago

1.3.9

1 year ago

1.3.8

1 year ago

1.2.13

1 year ago

1.2.16

1 year ago

1.2.17

1 year ago

1.2.14

1 year ago

1.2.15

1 year ago

1.2.18

1 year ago

1.2.19

1 year ago

1.3.7

1 year ago

1.3.6

1 year ago

1.3.5

1 year ago

1.3.4

1 year ago

1.3.3

1 year ago

1.3.2

1 year ago

1.3.1

1 year ago

1.2.20

1 year ago

1.2.21

1 year ago

1.2.22

1 year ago

1.2.9

1 year ago

1.2.12

1 year ago

1.2.10

1 year ago

1.2.11

1 year ago

1.2.8

1 year ago

1.2.7

1 year ago

1.2.6

1 year ago

1.2.0

1 year ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.2.5

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.0.20

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago