GeekyAnts / NativeBase

Mobile-first, accessible components for React Native & Web to build consistent UI across Android, iOS and Web.
https://nativebase.io/
MIT License
20.21k stars 2.39k forks source link

Checkbox text overflows out of container #5264

Open darrenkeen opened 2 years ago

darrenkeen commented 2 years ago

Description

When using the Checkbox component, having some long text results in content going off the screen or out of the containers width.

CodeSandbox/Snack link

https://snack.expo.dev/K6hps6IFF

Steps to reproduce

Expo: 44.0.6 Native Base: 3.4.11 React: 17.0.1 React Native: 0.64.3

import { Box, Checkbox, NativeBaseProvider } from 'native-base';

export default function App() {
  return (
    <NativeBaseProvider>
      <Box>
        <Checkbox isInvalid value="invalid" mt={10}>
          This is a long bit of text inorder to go out of this page and see the
          issue
        </Checkbox>
      </Box>
    </NativeBaseProvider>
  );
}

I took a basic expo app to show this problem

Screenshot 2022-08-10 at 22 56 34

NativeBase Version

3.4.11

Platform

Other Platform

No response

Additional Information

No response

Viraj-10 commented 2 years ago

Hi @darrenkeen, Thanks for reporting the issue. we will look into it.

floriandevo commented 2 years ago

I have a different problem with a long text. The checkbox icon take all height of the screen.

image

To resolve it, I add the style below :

return (
    <Checkbox value={'one'} _text={{ width: '100%', flex: 1 }} width={'100%'}>
      This is a long bit of text inorder to go out of this page and see the issue
    </Checkbox>
)
sahilvasuja commented 1 year ago

Hey, You can try this code 👇

import { Box, Checkbox, NativeBaseProvider, Text } from 'native-base';

export default function App() {
  return (
    <NativeBaseProvider>
      <Box>
        <Checkbox isInvalid value="invalid" mt={10}>
         <Text style={{flex: 1, flexWrap: 'wrap'}}>  This is a long bit of text inorder to go out of this page and see the issue
   </Text>
        </Checkbox>
      </Box>
    </NativeBaseProvider>
  );
}
dhcmega commented 8 months ago

Hi This also works:

<HStack space={1} >
    <Text bold>Descripción:</Text>
    <Text flex flexWrap="wrap" >{pet.description}</Text>
</HStack>
gabrielpdsilva commented 4 months ago

@dhcmega in Text component I think it should be flex={1} instead of only flex.