Socket
Socket
Sign inDemoInstall

react-native-box-lite

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-native-box-lite

Box lite for React Native, It's good for web developer to move to mobile developer


Version published
Weekly downloads
14
increased by7.69%
Maintainers
1
Install size
276 kB
Created
Weekly downloads
 

Readme

Source

react-native-box-lite

components-demo

Installation

$ npm install react-native-box-lite

Extension for react-native-box-lite

To use suggestion for className, you need to install extension react-native-components-intellisense in your vscode.

Usage

import {Box, Button, Text} from 'react-native-box-lite';
import {View} from 'react-native';

const test =()=>{
   const containerStyle = useClassName({
      className: "flex-1 bg-white p-4"
   })
   const containerHeaderStyle = useClassName({
      className: "bg-black p-4 h-10 w-screen"
   })

   return (
      <View style={containerStyles}>
         <Box style={containerHeaderStyle}>
            <Text className="text-white font-bold text-xl">
               Title Demo rn component
            </Text>
         </Box>
         <Box className="bg-amber-200 h-12 w-12">
            <Text className="text-white font-bold text-md">
               Demo rn component
            </Text>
         </Box>
         <Button title="Demo Button Default" />
         <Button varian="outline" title="Demo Button Outline" />
         <Button varian="primary" title="Demo Button Primary" />
      <View>
   )
}

Usage custom styles

  • use passed number in [] as w-[200] => width: 200
  • scale you can use function horizontalScale fontSize,... [${horizontalScale(30)}]
import {Box, Text} from 'react-native-box-lite';

const customStyles = () => {
  return (
    <Box>
      <Box className="w-[200] h-[350] bg-white center" />
      <Text className="text-[22] text-green-500 font-bold">
        Demo rn component
      </Text>
    </Box>
  );
};

Note

Type class Gap: support react-native version >= 0.71

HOOK: useClassName

PropDescriptionDefault
classNameclass of component as:w-1 h-1null
scaleScreenActive use scale by width of screentrue

Checkbox

PropDescriptionDefault
checkedstate checkedfalse
valuestate parameter when event pressnull
labellabel of checkboxnull
colorproperties checked and defaultchecked: blue, default: gray
sizesize of checkbox20
sizeChildrensize of state checked if has size && (!sizeChildren) => size/2 10
iconCheckedcustom icon checked, type: ImageSourcePropTypenull
renderIconCheckedfunction render icon checkednull
classNameclass styles of containernull
classNameParentclass styles of Parentnull
classNameChildrenclass styles of Childrennull
classNameLabelclass styles of Labelnull
isDebounceActive debounce when event pressfalse
delayDebouncetime debounce of debounce500
import {Checkbox} from 'react-native-box-lite';

<Checkbox label="Label" />
<Checkbox checked label="Checked" />
<Checkbox
   size={28}
   checked
   color={{checked: 'green'}}
   label="Custom color and size"
/>
 <Checkbox
   size={28}
   checked
   iconChecked={Add}
   color={{checked: 'green'}}
   label="Custom icon"
/>

example

RadioButton

PropDescriptionDefault
checkedstate checkedfalse
valuestate parameter when pressnull
labellabel of radionull
colorproperties checked and defaultchecked: blue,default: gray
sizesize of radio20
sizeChildrensize of state checked if has size && (!sizeChildren) => size/2 8
classNameclass styles of containernull
classNameParentclass styles of Parentnull
classNameChildrenclass styles of Childrennull
classNameLabelclass styles of Labelnull
isDebounceActive debounce when pressfalse
delayDebouncetime debounce of debounce500
import {RadioButton} from 'react-native-box-lite';

<RadioButton label="Label" />
<RadioButton checked label="Checked" />
<RadioButton
   size={28}
   checked
   color={{checked: 'green'}}
   label="Custom color and size"
/>

example

Box

PropDescriptionDefault
classNameclass styles of componentnull
scaleScreenActive use scale by width of screentrue
restextents from ViewProps
import {Box} from 'react-native-box-lite';

<Box className="row gap-2">
  <Box className="w-10 h-10 bg-red-400" />
  <Box className="w-10 h-10 bg-green-400" />
  <Box className="w-10 h-10 bg-yellow-400" />
</Box>;

example

Button

PropDescriptionDefault
variantype of primary, outline null
classNameclass styles of componentnull
scaleScreenActive use scale by width of screentrue
isDebounceActive debounce when pressfalse
delayDebouncetime debounce of debounce500
restextents from TouchableOpacityProps
import {Button} from 'react-native-box-lite';

<Button title="Demo Button Default" />
<Button varian="outline" title="Demo Button Outline" />
<Button varian="primary" title="Demo Button Primary" />

example

Text

PropDescriptionDefault
classNameclass styles of componentnull
scaleScreenActive use scale by width of screentrue
restextents from TextProps
import {Text} from 'react-native-box-lite';

<Text className="font-bold text-xl text-black">Text xl</Text>
<Text className="font-normal text-xl text-black">Font normal</Text>

example

scale screen

functionDescriptionparameter
horizontalScalescale by ratio width device default guidelineBaseWidth = 375number
verticalScalescale by ratio height device default guidelineBaseHeight = 812number
moderateScalescale by ratio width and heightnumber
fontSizescale by ratio width and heightnumber

Keywords

FAQs

Last updated on 15 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc