# Text color in GUI3D HolographicButton

**URL:** <https://forum.babylonjs.com/t/text-color-in-gui3d-holographicbutton/27195>\
**Category:** Questions\
**Created:** [January 28, 2022, 5:34pm UTC](https://forum.babylonjs.com/t/text-color-in-gui3d-holographicbutton/27195 "2022-01-28T17:34:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vladmandic](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/vladmandic/32/21473_2.png) [@vladmandic](https://forum.babylonjs.com/u/vladmandic)\
**Post date:** [January 28, 2022, 5:34pm UTC](https://forum.babylonjs.com/t/text-color-in-gui3d-holographicbutton/27195/1 "2022-01-28T17:34:19Z")

</div>

How do you control text color of `HolographicButton`?

Button itself has `backMaterial` and `frontMaterial` and that works as expected.

Text can be a string or a `TextBlock` set as content and color can be set there, but no matter what alpha values are chosen, its always blended with background making it incredibly difficult to read.

And this happens even if buttons front and back material have `alpha=1` - basically button becomes opaque, but text color is still blended with the background!

I’ve tried playing with `outlineColor` and `shadowColor` for `TextBlock` and they have the same issue.

Note that blending happens at the time of the first render only, it is not updated when scene is rotated.

```auto
createTextBlock(text: string) {
  const textBlock = new TextBlock();
  textBlock.text = text.replace(' ', '\n').toUpperCase();
  textBlock.color = Theme.btnFontColor;
  textBlock.alpha = 1;
  textBlock.fontFamily = 'Lato';
  textBlock.fontSize = 40;
  window.text = textBlock;
  return textBlock;
}

createButton(name: string, callback: Callback) {
  const btn = new HolographicButton(name, true);
  btn.onPointerDownObservable.add(() => callback(this.person));
  this.panel.addControl(btn);
  btn.backMaterial.albedoColor = Color3.FromHexString(Theme.btnBackColor);
  btn.backMaterial.alpha = Theme.btnBackAlpha;
  btn.frontMaterial.albedoColor = Color3.FromHexString(Theme.btnHighlighColor);
  btn.frontMaterial.hoverColor = Color4.FromHexString(Theme.btnHighlighColor);
  btn.frontMaterial.alpha = Theme.btnHighlightAlpha;
  btn.content = this.createTextBlock(name);
  window.panel = this.panel;
  return btn;
}

```

---

<div class="post-metadata">

**Author:** ![syntheticmagus](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/syntheticmagus/32/395_2.png) [@syntheticmagus](https://forum.babylonjs.com/u/syntheticmagus)\
**Post date:** [January 28, 2022, 6:21pm UTC](https://forum.babylonjs.com/t/text-color-in-gui3d-holographicbutton/27195/2 "2022-01-28T18:21:00Z")

</div>

Hi vladmandic,

You can access the text or other contents of the holographic button by using its [`content`](https://doc.babylonjs.com/typedoc/classes/babylon.gui.holographicbutton#content) property. I don’t think it’s guaranteed what this is out of the box, so be careful taking dependencies on the default implementation, but [right now it will default to being a `StackPanel` containing the `TextBlock` with the text in it](https://github.com/BabylonJS/Babylon.js/blob/master/gui/src/3D/controls/holographicButton.ts#L225-L255). The safest way to manipulate this would probably be to replace that control with your own, but you can also access the elements that happen to be in there directly and change the color that way, as shown on line 26 of the following Playground.

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

Hope this helps, and best of luck!

---

<div class="post-metadata">

**Author:** ![vladmandic](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/vladmandic/32/21473_2.png) [@vladmandic](https://forum.babylonjs.com/u/vladmandic)\
**Post date:** [January 28, 2022, 6:33pm UTC](https://forum.babylonjs.com/t/text-color-in-gui3d-holographicbutton/27195/3 "2022-01-28T18:33:28Z")

</div>

@syntheticmagus That’s exactly what I’m doing, see example above - the problem is that `TextBlock.alpha` property never goes to 1, it’s always blended with the background.

---

<div class="post-metadata">

**Author:** ![syntheticmagus](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/syntheticmagus/32/395_2.png) [@syntheticmagus](https://forum.babylonjs.com/u/syntheticmagus)\
**Post date:** [January 28, 2022, 7:06pm UTC](https://forum.babylonjs.com/t/text-color-in-gui3d-holographicbutton/27195/4 "2022-01-28T19:06:54Z")

</div>

_Hmm_, interesting, this is pretty funky. One thing you can do to strengthen the visibility is to change the diffuse color on the plate material to match the text color:

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

Hopefully that’s helpful, though probably not ideal. Ideally I think we’d like to be able to replace the plate material altogether, for example with an unlit PBR material, to give substantially more control over the appearance. That doesn’t seem to be possible with the current implementation, though, so if you need that much control you might need to make a new feature request on the [main repo](https://github.com/BabylonJS/Babylon.js).

---

<div class="post-metadata">

**Author:** ![vladmandic](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/vladmandic/32/21473_2.png) [@vladmandic](https://forum.babylonjs.com/u/vladmandic)\
**Post date:** [January 28, 2022, 8:21pm UTC](https://forum.babylonjs.com/t/text-color-in-gui3d-holographicbutton/27195/5 "2022-01-28T20:21:44Z")

</div>

> [@syntheticmagus](#):
>
> _Hmm_ , interesting, this is pretty funky. One thing you can do to strengthen the visibility is to change the diffuse color on the plate material to match the text color:
> 
> [Babylon.js Playground](https://playground.babylonjs.com/#HB4C01%23490)

setting `HolographicButton.plateMaterial.diffuseColor` to the same color as `textBlock.color` does the trick - thanks!
