# WordCountConfig

interface

The configuration of the word count feature.

```typescript
ClassicEditor
	.create( {
		wordCount: ... // Word count feature configuration.
	} )
	.then( ... )
	.catch( ... );
```

See [all editor options](module_core_editor_editorconfig-EditorConfig.md).

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-word-count/src/wordcountconfig.ts#L24)

<a id="properties">

## Properties

<a id="member-container">

### `container?: HTMLElement`

Allows for providing the HTML element that the [word count container](module_word-count_wordcount-WordCount.md#member-wordCountContainer) will be appended to automatically.

```typescript
const wordCountConfig = {
	container: document.getElementById( 'container-for-word-count' );
};
```

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-word-count/src/wordcountconfig.ts#L94)

<a id="member-displayCharacters">

### `displayCharacters?: boolean`

This option allows for hiding the character counter. The element obtained through [`wordCountContainer`](module_word-count_wordcount-WordCount.md#member-wordCountContainer) will only preserve the words part. Character counter is displayed by default when this configuration option is not defined.

```typescript
const wordCountConfig = {
	displayCharacters: false
};
```

The configuration above will result in the following container:

```html
<div class="ck ck-word-count">
	<div class="ck-word-count__words">Words: 4</div>
</div>
```

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-word-count/src/wordcountconfig.ts#L66)

<a id="member-displayWords">

### `displayWords?: boolean`

This option allows for hiding the word counter. The element obtained through [`wordCountContainer`](module_word-count_wordcount-WordCount.md#member-wordCountContainer) will only preserve the characters part. Word counter is displayed by default when this configuration option is not defined.

```typescript
const wordCountConfig = {
	displayWords: false
};
```

The configuration above will result in the following container:

```html
<div class="ck ck-word-count">
	<div class="ck-word-count__characters">Characters: 28</div>
</div>
```

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-word-count/src/wordcountconfig.ts#L45)

<a id="member-onUpdate">

### `onUpdate?: ( data: object ) => void`

This configuration takes a function that is executed whenever the word count plugin updates its values. This function is called with one argument, which is an object with the `words` and `characters` keys containing the number of detected words and characters in the document.

```typescript
const wordCountConfig = {
	onUpdate: function( stats ) {
		doSthWithWordNumber( stats.words );
		doSthWithCharacterNumber( stats.characters );
	}
};
```

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-word-count/src/wordcountconfig.ts#L82)

---

Full index of the CKEditor 5 API reference: [llms.txt](llms.txt)
