BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/utilcn/truncate-string

Truncate String

utilcn/truncate-string
FreeUtility

Truncate a string to a given length.

Install it

npx shadcn@latest add https://utilcn.dev/r/truncate-string.json

Source

registry/default/strings/truncate-string.tsutilcn.dev/r/truncate-string.json
1/**
2 * Truncates a string to a given length and appends an ellipsis ("...") if necessary.
3 *
4 * @param str - The input string.
5 * @param length - The maximum length of the string.
6 * @returns The truncated string with "..." if it exceeded the limit.
7 *
8 * @example
9 * truncate("Hello TypeScript World", 10); // "Hello Type..."
10 */
11export function truncateString(str: string, length: number): string {
12 return str.length > length ? `${str.slice(0, length)}...` : str;
13}

Files it writes

  • registry/default/strings/truncate-string.ts

Facts

Registry
utilcn
Type
registry:lib
Access
Free
Files written
1
Licence
the repository states none
First indexed
2026-08-04
Last confirmed
today

Go to the source

utilcn.dev BrennenRocks/utilcn on GitHub Raw registry item This item as JSON

More from utilcn

All 17 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
CapitalizecapitalizeutilcnUtilitiesFreeno deps
Capitalize Allcapitalize-allutilcnUtilitiesFreeno deps
Environment Server Configurationenv-serverutilcnUtilitiesFree1 dep
Generate Presigned Download URLgenerate-presigned-download-urlutilcnUtilitiesFree2 deps · 2 files
Generate Presigned Upload URLgenerate-presigned-upload-urlutilcnUtilitiesFree2 deps · 2 files
Repeat Padrepeat-padutilcnUtilitiesFreeno deps
Reverse Stringreverse-stringutilcnUtilitiesFreeno deps
To Camel Caseto-camel-caseutilcnUtilitiesFreeno deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex