0.1.5 • Published 6 months ago

react-native-box-lite v0.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

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/210
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/28
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, outlinenull
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
0.1.6-beta.2

8 months ago

0.1.6-beta.3

6 months ago

0.1.6-beta.1

8 months ago

0.1.6-beta.4

6 months ago

0.1.5

8 months ago

0.1.4

8 months ago

0.1.2

9 months ago

0.1.3

9 months ago

0.1.0

10 months ago

0.1.1

10 months ago

0.0.9

11 months ago

0.0.8

11 months ago

0.0.7

11 months ago

0.0.6

11 months ago

0.0.5-beta.4

1 year ago

0.0.5-beta.5

1 year ago

0.0.5

1 year ago

0.0.5-beta.1

1 year ago

0.0.5-beta.2

1 year ago

0.0.5-beta.3

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago