From Documentation



It declares a component definition. You can use this to define your custom component which can extend the existing component or a completely-new component with it's own Java class or JavaScript widget.

Usage Examples

Set Default Value for Button in Application-scope




The name of the component. It must be unique in the whole language.



It specifies whether this definition is extending from another definition. If omitted, it is considered a definition of a new component. If specified, it extends from the given component definition (which must be defined first).

Notice that the component's name could be the same as the definition it extends from. If the same, the existent definition is simply overridden (no new component definition is created). It is a useful technique to change a component definition, such as adding annotation, providing the initial properties and so on.

depend required

if your component extends a component, most likely you need to specify <depends> to ensure parsing order.


[Required if no extends]

It specifies the component's Java class at the server side. It is required if you define a new component.


[Required if no extends][EL expressions allowed]

It specifies the widget's class at the client side. For Ajax clients, it must be a JavaScript class. It is required if you define a new component.

Since EL expressions are allowed, the widget class being associated with a component could be decided at runtime. Please refer to Blog: Totally Different Look per User Without Modifying Application for an example.


Any number of molds are allowed.

Custom Mold




[Optional][EL expressions allowed in the property value]

It specifies an initial property. Once the property is specified, the corresponding setter will be called when ZK Loader instantiates from a ZUML document. Of course, if you instantiate it directly in Java, this setting has no effect.

Suppose we want to make all window's border default to normal, we could do as follows.

Customization Reference


Another example , to turn off combobox's autocomplete.

    <component-name>combobox</component-name>                      <!-- required -->
    <component-class>org.zkoss.zul.Combobox</component-class>      <!-- required -->
    <widget-class>zul.inp.Combobox</widget-class>                  <!-- required -->



It specifies the name of the property to assign the text enclosed by the XML element. If omitted (default), the text will be interpreted as a label and a label component defined in label-template will be used.

For example, if you specify


then, the following ZUML document

<foo>the content of foo</foo>

will cause foo.setContent("the content of foo") to be called (assume foo is an instance of the component).



Specify a URI of a zul file as a template of this component. Support ~.. When you use the custom tag in a zul, ZK will inject the specified zul file like you use <apply templateURI="/my/long/path/mytemplate.zul"/>. If you specify this element, it will override <extends>.

Required zuti

This feature requires zuti module:


Define a Custom Component


Then those custom components are available in application scope, and you can use it in any zul like other components:


This can improve readability and reusability.

Last Update : 2023/03/20

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.