Free Use Bible API
Guide
Reference
SDKs
Seed Bible
GitHub
Support
  • English
  • Afrikaans
  • አማርኛ
  • العربية
  • বাংলা
  • Deutsch
  • Español
  • Français
  • Hausa
  • हिन्दी
  • Bahasa Indonesia
  • Italiano
  • 日本語
  • Português
  • Русский
  • Kiswahili
  • اردو
  • 简体中文
  • isiZulu
Guide
Reference
SDKs
Seed Bible
GitHub
Support
  • English
  • Afrikaans
  • አማርኛ
  • العربية
  • বাংলা
  • Deutsch
  • Español
  • Français
  • Hausa
  • हिन्दी
  • Bahasa Indonesia
  • Italiano
  • 日本語
  • Português
  • Русский
  • Kiswahili
  • اردو
  • 简体中文
  • isiZulu
  • Seed Bible
  • Guides
    • Developer Guide
    • Extension API
    • Security Model
  • API Reference (v1.18.0)
    • seed-bible/extensions
      • Classes

        • SandboxError
      • Interfaces

        • SandboxBook
        • SandboxChapter
        • SandboxChapterRef
        • SandboxChatMessage
        • SandboxChatRequest
        • SandboxCommentary
        • SandboxCommentaryBook
        • SandboxCommentaryChapter
        • SandboxCommentaryProfile
        • SandboxContext
        • SandboxDataset
        • SandboxDatasetBook
        • SandboxDatasetChapter
        • SandboxDatasetReference
        • SandboxDiscoverRequest
        • SandboxExtensionDefinition
        • SandboxFootnote
        • SandboxFriend
        • SandboxHighlight
        • SandboxNote
        • SandboxPaneHandle
        • SandboxPaneOptions
        • SandboxPlayback
        • SandboxPortalHandle
        • SandboxPortalOptions
        • SandboxProfile
        • SandboxReadingEvent
        • SandboxReadingPosition
        • SandboxReference
        • SandboxSave
        • SandboxSearchQuery
        • SandboxSearchResult
        • SandboxSearchResults
        • SandboxSelectedVerse
        • SandboxSessionParticipant
        • SandboxSharedSession
        • SandboxToolHandle
        • SandboxToolItemOptions
        • SandboxToolOptions
        • SandboxToolSelectContext
        • SandboxTranslation
        • SandboxVerseRef
        • SandboxViewProps
      • Type Aliases

        • SandboxCasualOSPattern
        • SandboxChapterContent
        • SandboxDiscoverResult
        • SandboxExtension
        • SandboxIcon
        • SandboxJsonValue
        • SandboxPermission
        • SandboxTitle
      • Variables

        • SANDBOX_PERMISSION_INFO
        • SANDBOX_PERMISSIONS
      • Functions

        • createSandboxClient
        • defineExtension
      • Unexported types
        • Interfaces

          • ChapterRef
          • SandboxInit
          • SandboxPermissionInfo
          • SandboxState
        • Type Aliases

          • SandboxErrorCode
          • SandboxFrameMode
          • SandboxPanePlacement
          • ToolFlag
    • seed-bible/extensions/testing
      • Interfaces

        • TestCall
        • TestHost
        • TestHostOptions
        • TestPane
      • Type Aliases

        • TestAnswer
      • Functions

        • createTestHost
      • Unexported types
        • Interfaces

          • SandboxCapture
          • SandboxMethods
          • SandboxToolDefinition
          • SandboxToolItem
        • Type Aliases

          • SandboxMethod
          • SandboxToolPatch
          • SandboxToolSurface
    • seed-bible/components
      • Interfaces

        • BottomSheetExpansion
        • BottomSheetProps
        • MaterialIconProps
        • PortalComponentHandle
        • PortalComponentProps
        • SearchBarProps
        • TranslationListProps
      • Type Aliases

        • ButtonProps
        • ButtonShape
        • ButtonSize
        • ButtonTone
        • ButtonVariant
        • CasualOSPattern
        • CloseButtonLook
        • CloseButtonSize
        • ContextMenuTriggerProps
        • ContextMenuWithButtonProps
        • IconButtonLook
        • IconButtonProps
        • IconButtonSize
        • SkeletonShape
      • Variables

        • AddIcon
        • AddTab
        • AiChatIcon
        • AiIcon
        • ApologistIcon
        • AskIcon
        • BibleIcon
        • BookmarkIcon
        • BookOutlineIcon
        • BurgerMenuIcon
        • CalendarStarIcon
        • ChatParticipantsIcon
        • ClientLogo
        • ColorSelect
        • CommunityIcon
        • CopyIcon
        • DiscordIcon
        • DonateIcon
        • DualScreenIcon
        • EditIcon
        • Eraser
        • ExtensionsIcon
        • FiltersIcon
        • FolderIcon
        • FormatLine
        • GoPrivateIcon
        • HighlightIcon
        • InfoSettingsIcon
        • JoinSession
        • LoadSpace
        • MarginIcon
        • MarginXIcon
        • MarginYIcon
        • MaterialIcon
        • MenuDown
        • MenuIcon
        • MinusIcon
        • MoreIcon
        • OpenFolderIcon
        • Panal
        • Panel1
        • Panel2
        • Panel3
        • Panel3Row
        • Panel4
        • Panel4Row
        • Playlist
        • PortalComponent
        • QuadScreenIcon
        • SbTabsIcon
        • SelectedIcon
        • SelectionUIIcon
        • SettingsIcon
        • ShareIcon
        • SingleScreenIcon
        • Space
        • SpaceDefaultIcon
        • SplitScreenIcon
        • StarIcon
        • StartSessionIcon
        • SupportIcon
        • T
        • TabsIcon
        • ThemeIcon
        • ThreeScreenIcon
        • TickIcon
        • TodayIcon
        • ToolbarIcon
        • UserAvatar
      • Functions

        • BottomSheet
        • Button
        • CloseButton
        • ContextMenuItem
        • ContextMenuWithButton
        • ExpandableText
        • IconButton
        • InstallAppsIcon
        • PlaylistLinkContent
        • SafariIcon
        • ScriptureLineHeightIcon
        • SearchBar
        • SeedBibleIcon
        • SeedBibleWordmark
        • Skeleton
        • SkeletonContainer
        • StopIcon
        • TranslationList
        • TranslationViewModeMenu
        • useDragReorder
      • Unexported types
        • Interfaces

          • Translation
          • TranslationLanguageGroup
          • UseDragReorderOptions
        • Type Aliases

          • CloseButtonProps
          • SvgIconProps
          • TranslationViewMode

Seed Bible extension API (v1.18.0) / seed-bible/components / ExpandableText

Function: ExpandableText()

function ExpandableText(props: {
  children: string;
  className?: string;
  lines?: number;
  readLessLabel: string;
  readMoreLabel: string;
}): Element | null;

Shows text with a "Read more" / "Read less" control when it does not fit. Collapsed, it reads as one line of prose — text... Read more — with the ellipsis and the control on the same baseline as the text. Expanded, the full text is shown with its line breaks preserved.

Whether it fits is measured, not estimated: the collapsed line is clipped by the browser and scrollWidth is compared against clientWidth on that same element — two real measurements of one element, so nothing has to be assumed about the font.

An earlier version instead built the budget by hand: one line of getComputedStyle().lineHeight, which is the keyword "normal" here, so it fell back to fontSize * 1.2. That guess lands inside a pixel of a real line box, and which side it lands on depends on the font's own metrics. Measured at this font size in Chromium: 1.15 for the default sans stack, so the guess held; 1.39 for a CJK fallback and 1.62 for a Thai one, where a single short line measured over the budget and every description, however short, was given a "Read more" that expanded to nothing. --sb-font-family is themeable and system-ui resolves per platform, so the guess was never one the component could make.

Labels are passed in already-translated so this stays i18n-agnostic (same pattern as SkeletonContainer).

Parameters

ParameterTypeDescription
props{ children: string; className?: string; lines?: number; readLessLabel: string; readMoreLabel: string; }-
props.childrenstring-
props.className?string-
props.lines?numberHow many lines to show before collapsing. Defaults to 1. Above 1, the text wraps within the budget rather than showing only its first line.
props.readLessLabelstringAlready-translated "Read less" label.
props.readMoreLabelstringAlready-translated "Read more" label.

Returns

Element | null

Prev
ContextMenuWithButton
Next
IconButton