Class Optgroup


@Marshalled(typeName="optgroup") public class Optgroup extends HtmlElementContainer<Optgroup>
DTO for an HTML <optgroup> element.

The optgroup element represents a group of option elements within a select element. It provides a way to organize related options into logical groups, making it easier for users to find and select the desired option. The label attribute provides the group heading.

Examples:

import static org.apache.juneau.bean.html5.HtmlBuilder.*; // Simple option group Optgroup optgroup1 = optgroup("Fruits", option("apple", "Apple"), option("banana", "Banana"), option("orange", "Orange") ); // Disabled option group Optgroup optgroup2 = optgroup("Vegetables", option("carrot", "Carrot"), option("broccoli", "Broccoli") ).disabled(true); // Multiple option groups in a select Select select1 = select("food", optgroup("Fruits", option("apple", "Apple"), option("banana", "Banana") ), optgroup("Vegetables", option("carrot", "Carrot"), option("broccoli", "Broccoli") ) );

The following convenience methods are provided for constructing instances of this bean:

See Also:
  • Constructor Details

    • Optgroup

      public Optgroup()
      Creates an empty Optgroup element.
    • Optgroup

      public Optgroup(Object... children)
      Creates an Optgroup element with the specified child nodes.
      Parameters:
      children - The child nodes. Must not be null.
  • Method Details

    • disabled

      public Optgroup disabled(Object value)
      disabled attribute.

      Whether the form control is disabled.

      This attribute uses deminimized values:

      • false - Attribute is not added
      • true - Attribute is added as "disabled"
      • Other values - Passed through as-is
      Parameters:
      value - The new value for this attribute. Typically a Boolean or String. Can be null to unset the attribute.
      Returns:
      This object.
    • label

      public Optgroup label(String value)
      label attribute.

      Specifies the user-visible label for the option group. This label is displayed in the select element to group related options together.

      The label should be descriptive and help users understand the grouping of options.

      Parameters:
      value - The user-visible label for the option group. Can be null to unset the attribute.
      Returns:
      This object.