Skip to main content

Check Box

The CheckBox is typically used to represent boolean values via a binary checked state.

FlexNative Checkbox is part of the @flexnative/inputs package. To use the FlexNative Checkbox you needs to install @flexnative/inputs package. Fallow this link on how to install the package.

API

import { Check, CheckProps } from '@flexnative/inputs';

Component

Check

Type: React.PureComponent<CheckProps<T>>

Properties

NameTypeRequiredDefault ValueDescription
valueTfalseundefinedRepresenting checkbox selected value.
typeCheckTypefalseinverse Check box fill mode.
warning
To have appearance for 'text', 'link', 'ghost', with custom color you should use hex colors.
sizeSizesfalsenormalCheck Box size.
radiusBorderRadiusfalsemediumCheck Box border radius.
borderWidthBorderWidthfalsehairlineCheck Box borders width.
borderColorColorValuefalseundefinedBorders color according react-native ColorValue.
checkedBorderColorColorValuefalseundefinedBorders color according react-native ColorValue.
disabledbooleanfalsefalseIndicator if input it is disabled or not.
colorInputColorfalsetheme.color.defaultColor by theme or a custom color according react-native ColorValue.
backgroundColorColorValuefalseundefinedInput background color.
checkedBackgroundColorColorValuefalseundefinedBackground color for active state according react-native ColorValue.
labelstring or React.ReactElementfalseundefinedA string value to display as labal, or React.ReactElement to display a custom element as a label.
labelStyleStyleProp<TextStyle> or ((state: StateCallbackType) => StyleProp<TextStyle>)falseundefinedEither text styles or a function that receives a boolean reflecting whether the component is currently active and returns text styles.
checkElementReact.ReactElementfalseundefinedCustom element to display on checked status.
unCheckElementReact.ReactElementfalseundefinedCustom element to display on unchecked status.
onChange(event: NativeSyntheticEvent<CheckboxEvent<T> ❘ SyntheticEvent<HTMLInputElement, <CheckboxEvent<T>>) => void;falseundefinedCallback that is invoked when the user presses the checkbox.
onValueChange(value: T) => voidfalseundefinedCallback that is invoked when the user presses the checkbox.

CheckType

One of 'outlined' | 'solid' | 'inverse'

NameTypeDescription
outlinedstringProperty to set checkbox with transparent background with borders.
solidstringProperty to fill in solid mode the background color of the checkbox component.
inversestringProperty to set transparent background of the checkbox component and with solid background on check state.

Sizes

One of 'small' | 'default' | 'medium' | 'large'

NameTypeValue
smallstringText size: FONT_SIZE.small
CheckBox size: FONT_SIZE.small * 1.5
defaultstringFonts size: FONT_SIZE.default
Icon size: FONT_SIZE.default * 1.5
mediumstringFonts size: FONT_SIZE.medium
Icon size: FONT_SIZE.medium * 1.5
largestringFonts size: FONT_SIZE.large
Icon size: FONT_SIZE.large * 1.5

BorderRadius

One of 'none' | 'small' | 'medium' | 'large' | 'full' | number

NameTypeValue
nonenumber0
smallnumber2
mediumnumber4
largenumber6
fullnumber99999
numberAny number value.

BorderWidth

One of 'none' | 'hairline' | 'thin' | 'base' | 'thick' | number

NameTypeValue
nonenumber0
hairlineStyleSheet.hairlineWidthThis is defined as the width of a thin line on the platform. It can be used as the thickness of a border or division between two elements.
thinnumber1
basenumber2
thicknumber3
numberAny number value

InputColor

One of 'default' | 'primary' | 'secondary' | 'info' | 'success' | 'warning' | 'error' | 'dark' | 'light' | ColorValue

Name Type ValuePreview
LightDark
backgroundColorValuetheme.colors.background #f8f8f8 #000000
defaultColorValuetheme.colors.default #f5f5f5 #404040
cardColorValuetheme.colors.card #ffffff #232323
textColorValuetheme.colors.text #424242 #ffffff
borderColorValuetheme.colors.border #42424226 #ffffff1A
placeholderColorValuetheme.colors.placeholder #0000001A #FFFFFF1A
infoColorValuetheme.colors.info #3e80ed #3e80ed
successColorValuetheme.colors.success #5ec232 #5ec232
warningColorValuetheme.colors.warning #ffc107 #ffc107
errorColorValuetheme.colors.error #d51923 #d51923
darkColorValuetheme.colors.dark #424242 #424242
secondaryColorValuetheme.colors.secondary #666666 #5C5C5C
lightColorValuetheme.colors.light #ebebeb #ebebeb
primaryColorValuetheme.colors.primary #ff6358 #ff6358
ColorValueAny ColorValue chosen by developer.

CheckboxEvent<T>

NameTypeRequiredDefault ValueDescription
valueTfalseundefinedA value representing current checkbox value.
targetanyfalseundefinedOn native platforms, a NodeHandle for the element on which the event has occurred. On web, a DOM node on which the event has occurred.

Usecase Examples

The following example demonstrates the FlexNative CheckBox in action.

Value

Object value: 

String value: 

Boolean value: 

Type

Sizes

Radius

Colors

Border Width

Border Colors

Checked Border Colors

Disabled

Background Color

Checked Background Color

Label

Custom Check Element

Using as Radio Button

{"id":1,"color":"red"}

Playground

Live Editor
//Play with props to see live changes;

function CheckPlayground() {
  const [value, setValue] = useState(true);

  return (
    <Check value={value}
          label='Try check box'
          type='inverse'
          size='large'
          radius='large'
          color='primary'
          borderWidth='thick'
          onValueChange={() => setValue(!value)}
    />
  );
}

render(<CheckPlayground />);
Result
Loading...