HTML Text error

I’m getting this error Cannot add a class to the Text component because it doesn't represent an HTML Element but a text Node on the client side..
The code is Text warningNote = new Text("Note: This operation cannot be undone"); warningNote.addClassName(LumoUtility.TextColor.SECONDARY);. Is adding class name not allowed to Text though there is no error when adding ?

Yes, it’s not an html element, so it cannot have a classname. Which is what the error says.

The reason that it has the classname api at all is that it’s defined in the Component class, and Text extends Component.

So you’ll probably want a Span.