Last active
October 20, 2025 22:09
-
-
Save pH-7/18b8ea2843d8720b65b501a551990262 to your computer and use it in GitHub Desktop.
React Native Line Break component - Add line breaks easily in your React Native app. Follow my AI Software Engineering Journey on https://PierreHenry.dev
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * (c) 2024 Pierre-Henry Soria. | |
| */ | |
| import { StyleSheet, View, ViewStyle, DimensionValue } from 'react-native'; | |
| type LineBreakProps = { | |
| width?: DimensionValue; | |
| color?: string; | |
| style?: ViewStyle; | |
| }; | |
| const colors = { | |
| whiteOpacity20: 'rgba(255, 255, 255, 0.2)', | |
| }; | |
| export const LineBreak = ({ | |
| width = '80%', | |
| color = colors.whiteOpacity20, | |
| style, | |
| }: LineBreakProps) => { | |
| return ( | |
| <View style={s.container}> | |
| <View style={[s.lineBreak, { width, backgroundColor: color }, style]} /> | |
| </View> | |
| ); | |
| }; | |
| const s = StyleSheet.create({ | |
| container: { | |
| width: '100%', | |
| alignItems: 'center', | |
| paddingVertical: 16, | |
| }, | |
| lineBreak: { | |
| height: StyleSheet.hairlineWidth, | |
| borderRadius: StyleSheet.hairlineWidth / 2, | |
| }, | |
| }); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage (here, with a 75% line):