Text Component

A styled text component for React Native that provides consistent typography and theming capabilities with additional text styling variants.

Features

  • šŸŽØ Theme Integration - Seamlessly integrates with the design system
  • šŸ“ Multiple Variants - Regular, Bold, and Italic text styles
  • šŸŽÆ Customizable - Override colors, fonts, and sizes easily
  • ♿ Accessible - Inherits all React Native Text accessibility features
  • šŸ”§ TypeScript Ready - Full type safety and IntelliSense support
  • šŸŽŖ Styled Components - Built with styled-components for optimal performance

Installation

šŸ’»Bash
npm install rn-base-component
# or
yarn add rn-base-component

Basic Usage

āš›ļøTSX
import React from 'react'
import { Text } from 'rn-base-component'

export default function App() {
  return Hello, World!
}

Text Variants

Regular Text

āš›ļøTSX
import { Text } from 'rn-base-component'

This is regular text

Bold Text

āš›ļøTSX
This is bold text

Italic Text

āš›ļøTSX
This is italic text

Customization

Custom Color

āš›ļøTSX
Blue text
Bold red text
Italic green text

Custom Font Size

āš›ļøTSX
Large text
Small text

Combined Styling

āš›ļøTSX

  Centered text with custom styling

API Reference

TextProps

PropTypeDefaultDescription
colorstringtheme.textColorText color
fontSizenumbertheme.fontSizeFont size
styleStyleProp<TextStyle>undefinedAdditional text styles
childrenReact.ReactNodeRequiredText content

Inheritance

All React Native TextProps are supported, including numberOfLines, ellipsizeMode, selectable, onPress, etc.

Layout Examples

Content Structure

āš›ļøTSX
import React from 'react'
import { View } from 'react-native'
import { Text } from 'rn-base-component'

export default function ContentExample() {
  return (
    
      
        Article Title
      
      
      
        Published on March 15, 2024
      
      
      
        This is a paragraph of text that demonstrates how to use the Text 
        component for content layout. The component inherits all the styling 
        capabilities of React Native's Text component while providing 
        additional theming support.
      
      
      
        Last updated 2 hours ago
      
    
  )
}

const styles = StyleSheet.create({
  container: {
    padding: 20,
  },
  meta: {
    marginVertical: 8,
  },
  paragraph: {
    lineHeight: 22,
    marginVertical: 16,
  },
})

User Interface Elements

āš›ļøTSX

  John Doe
  Software Engineer
  
    Last seen 2 hours ago
  

Status Messages

āš›ļøTSX
āœ“ Operation completed successfully
āœ— Error occurred during operation
⚠ Warning: Check your input

Theme Integration

Using Theme Colors

āš›ļøTSX
import { useTheme } from 'rn-base-component'

const theme = useTheme()

Primary colored text
Secondary colored text
Error colored text

Responsive Text

āš›ļøTSX
Large text
Medium text
Small text

Best Practices

  1. Consistent Typography - Use the Text component for all text to maintain consistency
  2. Readable Colors - Ensure sufficient contrast between text and background
  3. Appropriate Sizing - Use appropriate font sizes for different content types
  4. Theme Integration - Leverage theme colors and font sizes
  5. Accessibility - Test with screen readers and ensure proper contrast
  6. Performance - Use Text variants instead of inline styling when possible

Performance Tip

The Text component is optimized with styled-components for better performance compared to inline styling.

Common Patterns

Error States

āš›ļøTSX

  Please enter a valid email address

Loading States

āš›ļøTSX
Loading...

Empty States

āš›ļøTSX

  No items found

āš›ļøTSX

  Learn more