Text handbook
v3.5.4 · @snowui-design-system/components
License: Before reading component documentation, source, or npm usage instructions for the first time, read the full LICENSE. Reuse that review for the same task and version. Public API configuration and internal implementation changes have different license implications. All components use the unified runtime package; source rights remain governed by the license.
Overview
Display text with consistent typography and truncation for body copy, labels, and space-limited information.
When to use it
Use Text for semantic text, truncation, expansion, and supplementary tooltips. Hover motion is off by default. Plain static copy may use semantic HTML; choose a motion component for animated numbers or text.
tagchooses the text element,linescontrols truncation, andmoreortooltipsupplies expansion or additional information.No hover interaction runs by default.
stateTextcan replace copy by state;partsconfigures built-in Button and Tooltip instances.With lines=1, shortened visible text retains its complete accessible name, including when used inside a button, link or native label.
Quick start
This example shows the recommended basic composition. See the sections below for more cases and composition limits.
API
See the base component documentation for inherited capabilities not redeclared here. This table lists only named public Props declared by this component.
Usage boundaries and details
Built-in component dual mode
parts.Button: Configure the built-in expansion button generated bylines=0 + more.parts.Tooltipconfigures the built-in tooltip shown for truncated content.External Tooltip or other children are not controlled by Text's private DOM selector.
Inheritance: Text retains Frame’s general interaction, motion, responsive, and appearance features. Defaults: enableResponsive=false, enableContext=true, enableScaleObserver=false. Ownership: Text implements lines and onTruncate itself; Frame routes shared capabilities.
Without lines, truncation remains dormant: it does not read text, queue animation frames, or register MutationObserver/ResizeObserver. Setting lines later activates the existing protocol without changing the default appearance.
Layout model
Main layout model: text flow layout.
Text preserves HTML text flow, semantic tags, truncation, and tooltip/more positioning. It does not register as a slot host, inline shell, or composite layout.
tagdetermines the text flow display mode such asblock / inline-block / list-item / code;lines=0/1/2/3only changes the truncation and mask, not the main layout model of the component.<Tooltip as="tooltip">and<Button as="more">are role children. Tooltip explains truncated content; Button keeps its own inline-shell layout.Text uses no padding or gap to arrange children and no margin to change surrounding text flow. Interactive displacement uses transform variables only.
1.1 Overview of functions
Smart truncation:
Textdirectly supportslines={0|1|2|3}andonTruncate; single-line mode reusesfitTextToElement()to stably display the explicit ellipsis that follows the text.Complete accessible text: Single-line truncation keeps shortened text visual-only and reuses the existing fullText and bundled visually hidden style for the complete plain-text name. Parent buttons, links and native labels retain their full name. It does not render an interactive snippet twice or add a measurement controller.
Built-in expansion: With
lines=0,moremay enable the built-in ArrowLineDown Button; it is off by default. The button uses the same backdrop blur as BarChart’s blur overlay.Scroll mode: With
lines=0and no More button, content uses Textarea’s shared top/bottom fade and overlay scrollbar. Showing More switches to expansion mode without a scrollbar.Role-oriented combination:
<Tooltip as="tooltip">: The prompt automatically displayed when truncated.<Button as="more">: Expand/collapse control.
Responsive:
tag/classcan be overwritten throughresponsive.Motion: Inherits Frame triggers such as
whileHoverandwhileClick.
1.2 Keyword Definition (Keywords)
stateText parsing rules
Textreads thecurrentStateof the recent parent Frame Context.Render the text when the current state hits
stateText[currentState].If the current state has no match, fall back to
stateText.Idle.If
stateTextis absent or unresolved, renderchildren.stateTextis only used to replace text with the same structure, and does not carry complex DOM. Complex custom subtrees are still exception scenarios ofstateContent.
Loadis reserved for Frame’s loading/Skeleton protocol. For a button task in progress that still shows real copy, preferPending.
1.3 Usage example
1. Basic style
2. Layout Modes (Layout Modes)
3. Hover interaction
Closed by default; only effective when interactive === true:
5. Truncation and expandable style (lines=0/2/3)
Text style overlay
Read the full LICENSE first; reuse that review for the same task, version, and scope.
First use public component Props to match the desired appearance, preserving the existing look where possible. If changes are necessary, follow the style selection and override order: use your own class (including Tailwind already in the project) or an instance style. The names below are public overrides actually consumed by source; check their scope and do not modify private DOM. Choose the correct SnowUI token family. External apps need not install SnowUI website utilities.
Text type and status
Required Props: no named required Props.
Two-way binding: bind:element.
Inheritance: FrameProps. Consult the base class public documentation; fields excluded by Omit cannot be passed through unchanged.
The following type declarations are actually referenced by public Props and come from source. A Svelte Snippet denotes a content fragment; ComponentProps denotes the Props of the corresponding component.
StateValueMap
Source: components/src/logic/frame-types.ts
CoreState
Source: components/src/logic/frame-types.ts
TooltipProp
Source: components/src/components/Text.svelte
ComponentPartsOf
Source: components/src/logic/component-parts.svelte.ts
ConfigurableComponentPartProps
Source: components/src/logic/component-parts.svelte.ts
ComponentPartControlledKey
Source: components/src/logic/component-parts.svelte.ts