# Custom CSS Light & Dark Mode

**URL:** <https://forum.radzen.com/t/custom-css-light-dark-mode/21593>\
**Category:** Radzen.Blazor Components\
**Created:** [June 25, 2026, 3:00am UTC](https://forum.radzen.com/t/custom-css-light-dark-mode/21593 "2026-06-25T03:00:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kirank](https://forum.radzen.com/letter_avatar_proxy/v4/letter/k/a87d85/32.png) [@kirank](https://forum.radzen.com/u/kirank)\
**Post date:** [June 25, 2026, 3:00am UTC](https://forum.radzen.com/t/custom-css-light-dark-mode/21593/1 "2026-06-25T03:00:10Z")

</div>

I’m trying to create custom css for read only textboxes and ensure they display well for light as well for dark modes. So I’m trying to set up a background color for light mode and another for dark mode.

I know that the RazenLayout changes depending on dark or light modes ie. for Fluent Theme, for light sets a css style of rz-fluent and for dark mode sets rz-fluent-dark.

This could work, however, the issue is that the textbox are in a Dialog and the code generated for a dialog sits outside of the layout.

Is there a workaround for the above for a Dialog?

---

<div class="post-metadata">

**Author:** ![yordanov](https://forum.radzen.com/user_avatar/forum.radzen.com/yordanov/32/8020_2.png) [@yordanov](https://forum.radzen.com/u/yordanov)\
**Post date:** [June 25, 2026, 1:53pm UTC](https://forum.radzen.com/t/custom-css-light-dark-mode/21593/2 "2026-06-25T13:53:08Z")

</div>

Hi @kirank,

You could use the `:has()` pseudo-class to check if the `<body>` has a child (in our case rz-layout) with a matching \*-dark css class and then cascade in:

```html
<style>
  /* dark: any Radzen dark theme active anywhere in the document */
  body:has(.rz-layout[class*="-dark"]) .rz-dialog .rz-textbox {
    background-color: #000000;
  }

  /* light: dialog when the layout is a non-dark theme */
  body:has(.rz-layout:not([class*="-dark"])) .rz-dialog .rz-textbox {
    background-color: #ffffff;
  }
</style>

```

---

<div class="post-metadata">

**Author:** ![kirank](https://forum.radzen.com/letter_avatar_proxy/v4/letter/k/a87d85/32.png) [@kirank](https://forum.radzen.com/u/kirank)\
**Post date:** [June 27, 2026, 11:58pm UTC](https://forum.radzen.com/t/custom-css-light-dark-mode/21593/3 "2026-06-27T23:58:50Z")

</div>

Thank you. That works.
