shadimage
utilcn
libcapitalizesource: ok · hit

Capitalize

Capitalize the first letter of a string.

npx shadcn add "https://utilcn.dev/r/capitalize.json"
free

Interaction

text-animation

Tags auto-generated by rules on 9/24/2026 — empty means no evidence, not lack of support.

Files1 · source cached 10/11/2026, 6:02:19 PM

registry/default/strings/capitalize.ts
/**
 * Capitalizes the first character of a string.
 *
 * @param str - The input string.
 * @returns The string with the first character uppercased.
 *
 * @example
 * capitalize("typescript"); // "Typescript"
 */
export function capitalize(str: string): string {
  if (!str) return '';
  return str.charAt(0).toUpperCase() + str.slice(1);
}

More from utilcn

Browse all components in this library →