Skip to main content

Check List

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.

React component that allows users to select items from a list. Component extending React.PureComponent, which is optimized for performance by implementing a shallow prop and state comparison. It supports both single and multiple selection modes based on the 'multipleSelect' prop. The component maintains its selected items in the state and updates the selection when an item is pressed. It also provides styling options through various props and handles rendering of labels and helper text conditionally.

API

import { CheckList, CheckListProps } from '@flexnative/inputs';

Component

CheckList

Type: React.PureComponent<CheckListProps<T>>

Properties

NameTypeRequiredDefault ValueDescription
valueT ❘ Array<T>falseundefinedRepresenting selected value/values from the available list.
valueFieldstringfalseundefinedWhen the selected item is an object, always specify valueField. If you do not set a value for the field, the list will compare the items by reference, which may complicate debugging. For example, the selected value will not be applied, if it does not reference the exact passed data object.
typeInputTypefalseoutlinedChecklist borders mode.
multipleSelectbooleanfalsetrueBoolean value for single or multiple selection.
sizeSizesfalsenormalCheck list sizes.
radiusBorderRadiusfalsemediumCheck list border radius.
borderWidthBorderWidthfalsehairlineCheck list borders width.
borderColorColorValuefalseundefinedBorders color according react-native ColorValue.
disabledbooleanfalsefalseIndicator if input it is disabled or not.
colorColorfalsetheme.color.defaultColor by theme or a custom color according react-native ColorValue.
backgroundColorColorValuefalseundefinedInput background color.
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.
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.
direction'row' | 'column'falsecolumnCheck element direction.
materialbooleanfalsefalseIndicator if input should looks like Material input.
helperTextstringfalseundefinedHelper text about input.
childrenArray<CheckProps<T>>falseundefinedReact element to render custom check boxes.

InputType

One of 'outlined' | 'underlined'

NameTypeDescription
outlinedstringProperty to set check list with borders.
underlinedstringProperty to set check list underlined, (with only bottom border).

Color

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

Name Type ValuePreview
LightDark
whiteColorValuetheme.colors.white #FFFFFF #FFFFFF
blackColorValuetheme.colors.black #424242 #424242
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
overlayColorValuetheme.colors.overlay #00000021 #FFFFFF21
ColorValueAny ColorValue chosen by developer.

Playground

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

function CheckListPlayground() {
  const [textValues, setTextValues] = useState(['1', '2', '3']);

  return (
    <CheckList label='Check list label'
              value={textValues}
              color='success'
              size='large'
              backgroundColor='default'
              borderColor='info'
              borderWidth='thick'
              radius='medium'
              onValueChange={(newValues) => setTextValues([...newValues])}>
      <Check value='1' label='Check 1' />
      <Check value='2' label='Check 2' />
      <Check value='3' label='Check 3' color='primary' />
    </CheckList>
  );
}

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