Skip to content

getInitials

getInitials(name): string

Defined in: packages/ui/src/components/avatar-with-initials.tsx:17

Extracts up to two uppercase initials from a full name.

Splits the name on spaces and takes the first character of each part.

string

The full name to extract initials from.

string

A string of 1-2 uppercase characters (e.g. "DS" for "Daniel Schmidt").

getInitials("Daniel Schmidt"); // "DS"
getInitials("Alice"); // "A"