Pricing

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.

  • tag chooses the text element, lines controls truncation, and more or tooltip supplies expansion or additional information.

  • No hover interaction runs by default. stateText can replace copy by state; parts configures 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.

<script lang="ts">	import { Text, Button, Frame } from '@snowui-design-system/components';</script> <div style="width: min(100%, 24rem); min-width: 0;">	<Text lines={1} tooltip style="font-size: var(--text-14); line-height: var(--leading-14); width: 100%;">Design system documentation — component behavior, accessibility, and release notes</Text></div>

API

Keyword Type Default Description
tag string — Root element tag; defaults to span.
stateText StateValueMap<string | number> — Render text for the nearest parent Frame’s currentState. Fall back to stateText.Idle, then children.
interactive boolean false Enable Text hover motion only when explicitly set to true; off by default.
lines 0 | 1 | 2 | 3 — Text truncation mode: 0 = expandable, 1/2/3 = fixed number of lines.
more boolean false Generate a built-in expansion Button when lines=0; the default style is the ArrowLineDown button in Example 6.
tooltip TooltipProp — Tooltip configuration: derive text automatically, pass fixed text or a Snippet, or pass an object to override placement, offset, and other Tooltip settings.
onTruncate (isTruncated: boolean) => void — Truncation state change callback.
children Snippet<[any]> — Default text or custom content, receiving a render context with the breakpoint. Matching stateText replaces it with the state-specific text.
parts ComponentPartsOf<{ Button: typeof Button; Tooltip: typeof Tooltip; }> — Configure built-in Button and Tooltip instances only; same-named components passed as children do not inherit these parts.

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 by lines=0 + more.

  • parts.Tooltip configures 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.

  • tag determines the text flow display mode such as block / inline-block / list-item / code; lines=0/1/2/3 only 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: Text directly supports lines={0|1|2|3} and onTruncate; single-line mode reuses fitTextToElement() 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, more may 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=0 and 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 / class can be overwritten through responsive.

  • Motion: Inherits Frame triggers such as whileHover and whileClick.

1.2 Keyword Definition (Keywords)

Keyword Type Default Description
variants object undefined Style variant configuration (for Layout use).

stateText parsing rules

  1. Text reads the currentState of the recent parent Frame Context.

  2. Render the text when the current state hits stateText[currentState].

  3. If the current state has no match, fall back to stateText.Idle.

  4. If stateText is absent or unresolved, render children.

  5. stateText is only used to replace text with the same structure, and does not carry complex DOM. Complex custom subtrees are still exception scenarios of stateContent.

Load is reserved for Frame’s loading/Skeleton protocol. For a button task in progress that still shows real copy, prefer Pending.

1.3 Usage example

 <Text>Plain text without truncation.</Text>  <Text lines={1}>Very long text that will be truncated...</Text>  <Text lines={1}>    Very long text that will be truncated...    <Tooltip as="tooltip">The full long text...</Tooltip></Text>  <Text lines={3}>A long paragraph is clamped to three lines...</Text>  <Text lines={0} class="bg-black-5 p-4 rounded-8">    Long content can be expanded...    <Button as="more" variant="borderless" class="text-blue">        Read more    </Button></Text>  <Text lines={0} more>    Long content can be expanded.</Text>  <Text lines={0} style="height: 5rem;">    Long content can scroll within a constrained height.</Text>  <Text    lines={1}    enableResponsive    class="text-12"    responsive={{        sm: { class: "text-14" },        lg: { class: "text-16" }    }}>    Responsive text...</Text>  <Button Click="Active" Active={["Idle", "auto"]} whileActive={{ duration: 2000 }}>    <Icon stateIcon={{ Idle: Paperclip, Active: Check }} />    <Text stateText={{ Idle: "Copy", Active: "Copied" }} /></Button>  <Button    Click={{ Idle: "Pending", Active: "Idle" }}    Pending={["Active", "auto"]}>    <Icon stateIcon={{ Idle: null, Pending: Spinner, Active: Check }} />    <Text stateText={{ Idle: "Ready", Pending: "Loading...", Active: "Completed" }} /></Button>

1. Basic style

Attribute Value Description
Class .snowui-text Component root class name
Box-Sizing border-box Box model standard
Min Width 0 Prevent flex overflow
Max Width 100% Limit the maximum width

2. Layout Modes (Layout Modes)

Model Class Display Applicable label
Block .snowui-text-block block p, h1-h6, div, etc.
Inline Block .snowui-text-inline-block inline-block span, a, strong, etc.
List Item .snowui-text-li list-item li
Tooltip anchor point .snowui-text-trigger-inline inline-flex lines=1 + tooltip trigger area
Tooltip Hug .snowui-text-tooltip-anchor-hug width: fit-content Truncate tooltip anchor width shrinkage
Code Override Contract code.snowui-text The component layer does not write font-size/line-height Let the code rule of snowui.css take effect naturally

3. Hover interaction

Closed by default; only effective when interactive === true:

Selector Attribute Value
.snowui-text-hover-enabled Transition transform 1000ms ease-out
.snowui-text-hover-enabled:hover:not(.snowui-disabled):not(:disabled) Transform displacement Inject through --snowui-text-hover-shift-x
.snowui-text-hover-enabled:hover:not(.snowui-disabled):not(:disabled) Hover displacement variable --snowui-text-hover-shift-x: 0.285em
.snowui-text-hover-enabled:hover:not(.snowui-disabled):not(:disabled) Cursor default (no forced pointer)

5. Truncation and expandable style (lines=0/2/3)

Selector Effect
.snowui-text-truncate-wrapper Wrap the content, keep width/height: 100%, as the carrier of the crop layer.
.snowui-text-collapse-motion-enabled Inject --snowui-text-collapse-transition for the real truncation/expanding link of lines=0/2/3, and merge the margin/transform transition of hover to avoid inline transition overwriting hover slowdown.
.snowui-truncate-container[data-lines="0"][data-expanded="false"] > .snowui-text-truncate-wrapper Close the state cropping, overflow: hidden.
.snowui-text-truncate-wrapper.snowui-scroll-mask Collapsed content uses the CSS form of the shared content-fade capability (.snowui-scroll-mask; see components/src/lib/edge-fade.md). data-scroll-mask="bottom" drives its mask-image.
.snowui-truncate-container .snowui-text-expand-button Linkage positioning of Button as="more": Button is declared as pin-bottom-right, with an edge spacing of 4px; Text raises it to the root layer, avoids the content mask, and hides it when it is expanded / not truncated.
.snowui-text-multi-line-content.snowui-line-clamp-2/3 Multi-line content independently carries display: -webkit-box + line-clamp; Tooltip remains in the Text root layer and does not enter the cropped text.
.snowui-text.snowui-line-clamp-2 Fix two lines: line-clamp: 2.
.snowui-text.snowui-line-clamp-3 Fixed three lines: line-clamp: 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.

Variable Purpose and default reference
--snowui-text-collapse-transition-override Folding transition (see the component source code for the default value)
--snowui-text-hover-transition-override Floating transition (see the component source code for the default value)
--snowui-text-mask-height-override Truncated bottom transparent fade height (default 2em)
--snowui-text-style-override Text style (see the component source code for the default value)

Design Guide · Token · Combination boundary

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.

Share Frame API · Return API

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

export type StateValueMap<T = any> = Partial<Record<CoreState, T>>;

CoreState

Source: components/src/logic/frame-types.ts

export type CoreState =    | "StartLoad"    | "Load"    | "Reload"    | "Appear"    | "Disappear"    | "Idle"    | "Active"    | "Disabled"    | "Validating"    | "Uploading"    | "Editing"    | (string & {});

TooltipProp

Source: components/src/components/Text.svelte

type TooltipProp = boolean | string | Snippet | Record<string, any>;

ComponentPartsOf

Source: components/src/logic/component-parts.svelte.ts

export type ComponentPartsOf<    T extends Record<string, Component<any>>,> = {    [K in keyof T]?: ConfigurableComponentPartProps<T[K]>;};

ConfigurableComponentPartProps

Source: components/src/logic/component-parts.svelte.ts

export type ConfigurableComponentPartProps<C extends Component<any>> = Partial<    Omit<ComponentProps<C>, ComponentPartControlledKey>>;

ComponentPartControlledKey

Source: components/src/logic/component-parts.svelte.ts

export type ComponentPartControlledKey =    | "children"    | "as"    | "value"    | "defaultValue"    | "open"    | "selected"    | "checked"    | "disabled"    | "readonly"    | "id"    | `on${string}`    | `aria-${string}`;