sp-truncated

Overview API Changelog

Description

Section titled Description

<sp-truncated> renders a line of text, truncating it if it overflows its container. When overflowing, a tooltip is automatically created that renders the entire non-truncated content.

It is used like a <span> to contain potentially-long strings that are important for users to see, even when in small containers, like full names and email addresses.

Usage

Section titled Usage

See it on NPM! How big is this package in your project?

yarn add @spectrum-web-components/truncated

Import the side effectful registration of <sp-truncated> via:

import '@spectrum-web-components/truncated/sp-truncated.js';

When looking to leverage the Truncated base class as a type and/or for extension purposes, do so via:

import { Truncated } from '@spectrum-web-components/truncated';

Example

Section titled Example
<sp-truncated>
    This will truncate into a tooltip if there isn't enough space for it.
</sp-truncated>

With specific overflow content

Section titled With specific overflow content

By default, tooltip text will be extracted from overflowing content. To provide your own overflow content, slot it into "overflow":

<sp-truncated placement="right">
    This is the inline content
    <span slot="overflow">
        And this overflow content will go into the tooltip, on the right
    </span>
</sp-truncated>

API

Changelog

1.0.1 (2024-11-11)

Section titled

Note: Version bump only for package @spectrum-web-components/truncated

1.0.0 (2024-10-31)

Section titled

Note: Version bump only for package @spectrum-web-components/truncated

0.49.0 (2024-10-15)

Section titled

Features

Section titled Features
  • add static-color to replace static (#4808) (43cf086)

0.48.1 (2024-10-01)

Section titled

Note: Version bump only for package @spectrum-web-components/truncated

0.48.0 (2024-09-17)

Section titled

Note: Version bump only for package @spectrum-web-components/truncated

0.47.2 (2024-09-03)

Section titled

Note: Version bump only for package @spectrum-web-components/truncated

0.47.1 (2024-08-27)

Section titled

Note: Version bump only for package @spectrum-web-components/truncated

0.47.0 (2024-08-20)

Section titled

Note: Version bump only for package @spectrum-web-components/truncated

0.46.0 (2024-08-08)

Section titled

Note: Version bump only for package @spectrum-web-components/truncated

0.45.0 (2024-07-30)

Section titled

Note: Version bump only for package @spectrum-web-components/truncated

0.44.0 (2024-07-15)

Section titled

Note: Version bump only for package @spectrum-web-components/truncated

0.43.0 (2024-06-11)

Section titled

Note: Version bump only for package @spectrum-web-components/truncated

0.42.5 (2024-05-24)

Section titled

Note: Version bump only for package @spectrum-web-components/truncated

0.42.4 (2024-05-14)

Section titled

Note: Version bump only for package @spectrum-web-components/truncated

0.42.3 (2024-05-01)

Section titled

Note: Version bump only for package @spectrum-web-components/truncated

0.42.2 (2024-04-03)

Section titled

Note: Version bump only for package @spectrum-web-components/truncated

0.42.1 (2024-04-02)

Section titled

Note: Version bump only for package @spectrum-web-components/truncated

0.42.0 (2024-03-19)

Section titled

Bug Fixes

Section titled Bug Fixes
  • truncated: add truncated package (#4163) (4ba0480)

Reverts

Section titled Reverts
  • Revert "Truncated element (#4125)" (#4160) (da88bbe), closes #4125 #4160