npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-native-arabic-autoheight-text

v1.0.7

Published

Smart Arabic/RTL text renderer for React Native using WebView: auto height, proper justification, line clamp, and skeleton loading.

Readme

🇸🇦 react-native-arabic-autoheight-text

Beautiful Arabic & RTL text inside WebView — Auto Height + Proper Typography

npm version license platforms TypeScript Friendly

A tiny, drop-in React Native component for Arabic / RTL text rendering with:

  • 🚀 Auto height inside WebView (no scrolling)
  • 🕌 Perfect RTL direction + proper justification
  • ✂️ Line clamping using CSS (-webkit-line-clamp)
  • 🎨 Converts TextStyle → WebView CSS
  • 🦴 Built-in / custom Skeleton loader
  • 🌙 Adaptive skeleton for dark mode
  • 📏 Supports fixed or dynamic layout with accuracy

Designed for: News, corporate content, About screens, product descriptions, long Arabic articles…


Demo 1 — Auto Height + RTL Justification

Demo 1

Demo 2 — Skeleton Loading State

Demo 2

Demo 3 — Multi-line clamp + Auto height

Demo 3


📦 Installation

yarn add react-native-arabic-autoheight-text react-native-webview react-native-skeleton-placeholder
# OR
npm install react-native-arabic-autoheight-text react-native-webview react-native-skeleton-placeholder

iOS

cd ios && pod install

🧩 Usage

Basic Example

<RtlTextView
  text="هذا النص سيتم ضبط ارتفاعه تلقائياً حسب المحتوى"
  textStyle={{ fontSize: 18, color: '#333' }}
/>

Line Clamping

<RtlTextView
  text="نص عربي طويل سيتم قصه بعد ثلاثة أسطر فقط..."
  numberOfLines={3}
  textStyle={{ fontSize: 16 }}
/>

Custom Skeleton

<RtlTextView
  text="جارٍ تحميل المحتوى..."
  textStyle={{ fontSize: 16 }}
  renderSkeleton={() => (
    <View style={{ height: 80, backgroundColor: '#DDD', borderRadius: 8 }} />
  )}
/>

🔥 Skeleton padding behavior (Recommended)

Skeleton auto-matches horizontal text padding → perfect alignment during loading

<RtlTextView
  text={longArabicText}
  textStyle={{ fontSize: 16, marginHorizontal: 20 }}
/>

💡 Skeleton width = full width — horizontal text margins

Full-width Skeleton (no margin)

<RtlTextView
  text={longArabicText}
  textStyle={{ marginHorizontal: 20 }}
  matchTextHorizontalPadding={false}
/>

WebView custom props

<RtlTextView
  text="Arabic Text"
  textStyle={{ fontSize: 16 }}
  webviewProps={{ showsVerticalScrollIndicator: false }}
/>

🔧 Props

| Prop | Type | Default | Description | | ---------------------------- | ------------------------------------------------ | -------------- | ------------------------------------------ | | text | string | — | Arabic text content | | textStyle | StyleProp<TextStyle> \| StyleProp<TextStyle>[] | — | Converted to CSS inside WebView | | numberOfLines | number | undefined | Max visible lines using CSS clamp | | isDark | boolean | false | Changes skeleton theme | | fontFamily | string | from textStyle | Override web font | | renderSkeleton | () => React.ReactNode | default | Custom skeleton UI | | skeletonHeight | number | 100 | Height during loading | | skeletonProps | Record<string, any> | {} | Props forwarded to Skeleton | | webviewProps | WebViewProps | {} | Forwarded to WebView | | containerStyle | StyleProp<ViewStyle> | {} | Outer wrapper styling | | matchTextHorizontalPadding | boolean | true | Copy text’s horizontal padding to skeleton |


🎨 Styling Details

Extracted CSS from last-defined textStyle value:

  • color, backgroundColor
  • fontSize, fontWeight, lineHeight, fontFamily
  • textAlign, RTL alignment enhancements
  • Margins: marginStart, marginEnd, marginHorizontal, marginVertical
  • WebView auto background transparency while loading

💡 marginStart + marginEnd recommended for RTL UI


🧠 Why WebView?

React Native <Text> still suffers with:

❌ Justified Arabic glyph shaping ❌ Broken connections in RTL ❌ Poor multi-line rendering ❌ No CSS multi-line clamp

This component fixes all of the above ✔️


🛠 Troubleshooting

| Issue | Fix | | ------------------------------ | ------------------------------------------- | | Skeleton too skinny | remove matchTextHorizontalPadding={false} | | Wrong first height | Font loader will update automatically | | Background shows while loading | WebView background auto-hidden |


🗺 Roadmap

🔹 Mixed LTR/RTL detection 🔹 “Read more” collapsed text 🔹 Full custom CSS styles 🔹 Accessibility enhancements

PRs welcome ✨


👤 Author

Built with ❤️ by Ahmed Hegazy 📧 [email protected] 🐙 GitHub: @ahmedhegazydev


📄 License

MIT — Free for commercial & open-source use