This page as markdown: /middle-truncate.md · Index for agents: /llms.txt · Everything in one file: /llms-full.txt

MiddleTruncate

Status: stable

Middle-truncates a long string (hash, address, signature) to 5J7s…8xQp, keeping the start and end legible while preserving the full value on hover.

Keywords: truncate, middle truncate, hash, identifier

Usage

Use MiddleTruncate when both the beginning and end of a long identifier must remain visible.

Best practices

Props

Name Type Default Description
text string — The full string to render. When it is truncated, the full value is also set as the title attribute (a pointer tooltip).
startChars number 6 How many leading characters to keep before the ellipsis.
endChars number 6 How many trailing characters to keep after the ellipsis.

Accessibility

Related

Examples

API key

import { MiddleTruncate } from "@sableui/react"

<MiddleTruncate text="demo_key_7f3a9c2e5b8d1f4a6c0e9b3d7a2f5c8e1b4" />

Custom start/end counts

import { MiddleTruncate } from "@sableui/react"

<MiddleTruncate text="9f2c4e7a1b3d5f60c8e2a4b6d8f0e1c3a5b7d9f2" startChars={4} endChars={4} />

Copyable value

import { Button, Icon, MiddleTruncate, Row, useCopy } from "@sableui/react"

const { copy, copied } = useCopy(commitHash)
<Row gap={1}><MiddleTruncate text={commitHash} /><Button variant="ghost" size="icon-xs" aria-label="Copy commit hash" onClick={copy}><span aria-hidden="true" className="motion-icon-swap"><span data-active={!copied} className="inline-flex"><Icon name="copy" /></span><span data-active={copied} className="inline-flex"><Icon name="check" /></span></span></Button><span role="status" className="sr-only">{copied ? "Copied" : ""}</span></Row>