RORK LABJP
ENGINE — Rork Max is powered by Claude Code and Claude Opus 4.6, generating native Swift apps directlyCORE ML — Rork Max reaches on-device Core ML inference alongside HealthKit, HomeKit, NFC, and App ClipsSEED — Rork raised a $15M seed led by Left Lane Capital in April 2026, joined by Peak XV and a16z SpeedrunM&A — Rork acquired the app builder Paperline and says it will stay acquisitive to bring in engineering talentMARKET — Gartner expects 75% of new applications to be built with low-code or no-code tools by the end of 2026GROWTH — The no-code AI platform market is projected to grow from $4.9B in 2024 to $24.8B by 2029ENGINE — Rork Max is powered by Claude Code and Claude Opus 4.6, generating native Swift apps directlyCORE ML — Rork Max reaches on-device Core ML inference alongside HealthKit, HomeKit, NFC, and App ClipsSEED — Rork raised a $15M seed led by Left Lane Capital in April 2026, joined by Peak XV and a16z SpeedrunM&A — Rork acquired the app builder Paperline and says it will stay acquisitive to bring in engineering talentMARKET — Gartner expects 75% of new applications to be built with low-code or no-code tools by the end of 2026GROWTH — The no-code AI platform market is projected to grow from $4.9B in 2024 to $24.8B by 2029
Articles/Dev Tools
Dev Tools/2026-07-04Intermediate

Should You Show a Read More Link? Let the Rendered Text Decide in Rork (Expo)

Clamping a product description to three lines and adding a Read more toggle sounds simple, until the toggle also appears under single-line text. This walks through measuring the real line count with onTextLayout so the toggle only shows when text actually overflows, covering iOS vs Android quirks, expand animation, and font scaling.

Rork498Expo139React Native201Text UIindie developer36

Premium Article

You add a Read more link under a product description, and then it shows up under a one-line blurb too. Building a wallpaper app on my own, I hit exactly this awkwardness on the detail screen and stopped to fix it properly. Long copy should collapse; short copy needs no toggle at all. The decision to show it or not should come from the number of lines that actually rendered, not from an unreliable proxy like character count. That is what this piece is about.

In React Native, which is the foundation the standard apps Rork generates sit on top of, a Text component will clamp and add an ellipsis when you set numberOfLines. What it will not do is tell you whether clamping happened. To show the toggle correctly, you have to measure whether the rendered body truly exceeds the line limit yourself.

Character counts always break somewhere

The first instinct is a threshold: show the toggle when the body passes 120 characters. It is easy, and it drifts almost immediately. Japanese and English fit wildly different amounts of text per line, and emoji, URLs, and line breaks all move the count. The same 100 characters land in two lines on a wide device and four lines on a small iPhone. Character count guarantees nothing about how many lines appear on screen.

I once shipped the threshold approach. It looked fine in Japanese, then the moment I switched to an English locale a wave of empty toggles appeared under short text. Moving the basis of the decision from input length to the rendered result looked like the long way around, but it was the reliable one.

Read the rendered line count with onTextLayout

React Native's Text has an onTextLayout callback. After the text is laid out, it hands you an array with information about each line. The line count is simply the length of that array.

The crucial detail: do not attach numberOfLines while measuring. If you do, the layout result is rounded to that limit, and you cannot tell whether the text was five lines clamped to three or genuinely three lines. So you measure once with no limit, look at the result, and decide whether the toggle is needed.

import { useState, useCallback } from 'react';
import { Text, Pressable, View, type TextLayoutEventData, type NativeSyntheticEvent } from 'react-native';
 
const COLLAPSED_LINES = 3;
 
type Props = { children: string };
 
export function ExpandableText({ children }: Props) {
  // needsToggle: does the body exceed 3 lines?
  // measured: have we measured once already?
  const [needsToggle, setNeedsToggle] = useState(false);
  const [measured, setMeasured] = useState(false);
  const [expanded, setExpanded] = useState(false);
 
  const onTextLayout = useCallback(
    (e: NativeSyntheticEvent<TextLayoutEventData>) => {
      if (measured) return; // ignore re-layouts after expanding
      const lineCount = e.nativeEvent.lines.length;
      setNeedsToggle(lineCount > COLLAPSED_LINES);
      setMeasured(true);
    },
    [measured],
  );
 
  return (
    <View>
      {/* Measurement pass: render once off-screen with no limit to get the count */}
      {!measured && (
        <Text
          onTextLayout={onTextLayout}
          style={{ position: 'absolute', opacity: 0, left: 0, right: 0 }}
          accessibilityElementsHidden
          importantForAccessibility="no-hide-descendants"
        >
          {children}
        </Text>
      )}
 
      {/* Display pass: clamp with numberOfLines only when collapsed */}
      <Text numberOfLines={expanded ? undefined : COLLAPSED_LINES}>
        {children}
      </Text>
 
      {needsToggle && (
        <Pressable
          onPress={() => setExpanded((v) => !v)}
          hitSlop={8}
          accessibilityRole="button"
          accessibilityLabel={expanded ? 'Collapse text' : 'Read more'}
        >
          <Text style={{ color: '#2563eb', marginTop: 4 }}>
            {expanded ? 'Show less' : 'Read more'}
          </Text>
        </Pressable>
      )}
    </View>
  );
}

The measurement Text is placed off-screen with absolute positioning and zero opacity, rendered once, then removed as soon as the count is known. The display Text applies numberOfLines only while collapsed. This two-layer approach lets you know whether clamping occurred while keeping flicker to a minimum. Always hide the measurement element from screen readers, or the reader will pick up the body twice.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
Measure the real rendered line count with onTextLayout and show Read more only when the body exceeds three lines, with working code you can drop in
Avoid the trap where measuring with numberOfLines still attached always rounds down to three lines, and learn why iOS and Android disagree on the count
See why the expand/collapse LayoutAnimation silently does nothing on Android, plus a toggle design that respects VoiceOver and 200% text size
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Rork Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

Dev Tools2026-07-10
Adding React Compiler to Expo Let Me Delete 41 Hand-Written memo Calls
I enabled React Compiler on Rork-generated React Native screens and measured the rerender counts with Profiler. Here is how I decided which memo and useCallback calls were safe to delete, how to find the components the compiler bailed out on, and how to catch regressions in CI.
Dev Tools2026-07-07
The App Icon Badge Still Says 3 — Rebuilding Expo Badge Counts Around a Single Source of Truth
Why an Expo app's icon badge drifts out of sync with real unread counts and refuses to clear — and how to rebuild it around a single source of truth, with working recompute-and-sync code and the production pitfalls that bite you.
Dev Tools2026-06-30
Adding Home-Screen Quick Actions to a Rork App — dynamic items without cold-launch drops
How to implement the long-press quick actions on a Rork (Expo) app icon. Covers static vs dynamic items, the iOS/Android differences, and the cold-launch problem where the action arrives before the router is ready — solved with a hold-and-replay design.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →