B4J Library [B4j] [DSE] CSSStyleClass Designer Script Extension

With the new Designer Script Extensions, Erel has given us Class Names for views similar to the B4j CSS class names.

For those wanting to use the actual CSS classes and styling in B4j, it is just as easy to add CSS class names to Nodes directly in the designer using the Designer Script Extensions.

This is a method to do just that. You can download the b4xlib and add that to your B4x additional libs folder, or just copy the method to any class.

Usage in the Designer Script:


You can also add more styleclasses and/or views in one go if you wish:

DSE_CSSStyleClass.AddStyleClass("button-sl, class-2",Button1,Button2,Button3)

'Parameters: ClassNames As String (Comma delimited), 1 or more Views comma delimited
'Designer Script : DSE_CSSStyleClass.AddStyleClass("button-sl",Button1,Button2,Button3)
Public Sub AddStyleClass(DesignerArgs As DesignerArgs)
#If B4j
    If DesignerArgs.FirstRun Then
        Dim ClassNames() As String = Regex.Split(",",DesignerArgs.Arguments.Get(0))
        For i = 1 To DesignerArgs.Arguments.Size - 1
            Dim V As Node = DesignerArgs.GetViewFromArgs(i)
            For Each ClassName As String In ClassNames
                ClassName = ClassName.Trim
                If V.StyleClasses.IndexOf(ClassName) = -1 Then
                End If
    End If
#End If
End Sub


  • DSE_Styleclass-b4xlib.b4xlib
    862 bytes · Views: 149
Last edited:


Licensed User
Longtime User
As an example you can put this useful sub in B4XMainPage.
I'm not sure I will be able to stop at one or two subs. I can see the case for a library or two of useful methods :). It's a great feature.