Skip to content
Gx
GitHub

GX5003: class string is built at runtime

A class value is made when the program runs: fmt.Sprintf, fmt.Sprint, strings.Join or a + with a value that is not a constant.

Cause

A class value is made when the program runs: fmt.Sprintf, fmt.Sprint, strings.Join or a + with a value that is not a constant. Tailwind reads the source files, so it cannot see a class that is made later.

Example

ui/card/Card.gx
package card

props {
  Size string
}

<article class={"p-" + p.Size}>Text</article>

gx check reports:

gx check
ui/card/Card.gx:7:17: GX5003: class string is built at runtime; Tailwind cannot see it

Fix

  1. Write each class as a full static string.
  2. Use a gx.Enum map to select one of a set of static strings.