BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/utilcn/repeat-pad

Repeat Pad

utilcn/repeat-pad
FreeUtility

Repeat a string until it reaches the desired length.

Install it

npx shadcn@latest add https://utilcn.dev/r/repeat-pad.json

Source

registry/default/strings/repeat-pad.tsutilcn.dev/r/repeat-pad.json
1/**
2 * Pads a string evenly on both sides until it reaches the desired length.
3 *
4 * @param str - The input string.
5 * @param length - Desired total length.
6 * @param pad - The character/string used as padding (default: space).
7 * @returns The padded string centered with the given padding.
8 *
9 * @example
10 * repeatPad("TS", 6, "-"); // "--TS--"
11 */
12export function repeatPad(str: string, length: number, pad = ' '): string {
13 const total = Math.max(length - str.length, 0);
14 const left = Math.floor(total / 2);
15 const right = total - left;
16 return pad.repeat(left) + str + pad.repeat(right);
17}

Files it writes

  • registry/default/strings/repeat-pad.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
Reverse Stringreverse-stringutilcnUtilitiesFreeno deps
To Camel Caseto-camel-caseutilcnUtilitiesFreeno deps
To Kebab Caseto-kebab-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