# Text alignment in InputBox (GUI)

**URL:** <https://forum.babylonjs.com/t/text-alignment-in-inputbox-gui/34630>\
**Category:** Questions\
**Created:** [October 9, 2022, 4:34pm UTC](https://forum.babylonjs.com/t/text-alignment-in-inputbox-gui/34630 "2022-10-09T16:34:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Johny\_Mickey](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/johny_mickey/32/24948_2.png) [@Johny\_Mickey](https://forum.babylonjs.com/u/Johny_Mickey)\
**Post date:** [October 9, 2022, 4:34pm UTC](https://forum.babylonjs.com/t/text-alignment-in-inputbox-gui/34630/1 "2022-10-09T16:34:48Z")

</div>

Hello there, please, is there some way to center the text in the “InputText” GUI component? The text should be in the middle of “Input text”. Thanks for your time.

---

<div class="post-metadata">

**Author:** ![Takemura](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/takemura/32/25836_2.png) [@Takemura](https://forum.babylonjs.com/u/Takemura)\
**Post date:** [October 9, 2022, 5:45pm UTC](https://forum.babylonjs.com/t/text-alignment-in-inputbox-gui/34630/2 "2022-10-09T17:45:15Z")

</div>

I would evaluate `margin`-property of `InputText`:

```auto
input.margin = 0.5*(width - advancedTexture.getContext().measureText(input.text).width) + 'px';

```

PG:

> **[Babylon.js Playground](https://playground.babylonjs.com/#1108TF%231)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

Additionally you can add observer of `onTextPasteObservable` for paste-cases.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [October 10, 2022, 2:09pm UTC](https://forum.babylonjs.com/t/text-alignment-in-inputbox-gui/34630/3 "2022-10-10T14:09:51Z")

</div>

@Takemura, you are on fire !!! thanks for all the help within the community !!!

---

<div class="post-metadata">

**Author:** ![Takemura](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/takemura/32/25836_2.png) [@Takemura](https://forum.babylonjs.com/u/Takemura)\
**Post date:** [October 10, 2022, 2:13pm UTC](https://forum.babylonjs.com/t/text-alignment-in-inputbox-gui/34630/4 "2022-10-10T14:13:58Z")

</div>

I have to thank aswell. It is a pleasure to work with you guys and participate on this awesome engine.
