[ Web Proxy ]
URL:
Viewing: https://angular.dev/api/common/TitleCasePipe [Back]  [Original]

TitleCasePipe Angular Skip to main content
menu
close
more_horiz
menuAPI
@angular/common

TitleCasePipe

pipe
stable

Transforms text to title case. Capitalizes the first letter of each word and transforms the rest of the word to lower case. Words are delimited by any whitespace character, such as a space, tab, or line-feed character.

LowerCasePipeUpperCasePipeBuilt-in Pipes

On this page

    arrow_upward_alt Back to the top

    Pipe usage

    {{ value_expression | titlecase }}

    API

        
          class TitleCasePipe implements PipeTransform {
    transform(value: string): string; transform(value: null | undefined): null; transform(value: string | null | undefined): string | null;
    }

    transform

    3 overloads
    @paramvaluestring

    The string to transform to title case.

    @returnsstring
    @paramvaluenull | undefined
    @returnsnull
    @paramvaluestring | null | undefined
    @returnsstring | null

    Description

    Transforms text to title case. Capitalizes the first letter of each word and transforms the rest of the word to lower case. Words are delimited by any whitespace character, such as a space, tab, or line-feed character.


    Exported by

    Usage Notes

    The following example shows the result of transforming various strings into title case.

    @Component({
      selector: 'titlecase-pipe',
      imports: [TitleCasePipe],
      template: `<div>
        <p>{{ 'some string' | titlecase }}</p>
        <!-- output is expected to be "Some String" -->
        <p>{{ 'tHIs is mIXeD CaSe' | titlecase }}</p>
        <!-- output is expected to be "This Is Mixed Case" -->
        <p>{{ "it's non-trivial question" | titlecase }}</p>
        <!-- output is expected to be "It's Non-trivial Question" -->
        <p>{{ 'one,two,three' | titlecase }}</p>
        <!-- output is expected to be "One,two,three" -->
        <p>{{ 'true|false' | titlecase }}</p>
        <!-- output is expected to be "True|false" -->
        <p>{{ 'foo-vs-bar' | titlecase }}</p>
        <!-- output is expected to be "Foo-vs-bar" -->
      </div>`,
    })
    export class TitleCasePipeComponent {}
    Jump to details

    Web Proxy Viewer  |  New URL  |  Original Page