Class SlotUtils


  • public class SlotUtils
    extends Object
    Util methods for handling child elements inside slots.
    Author:
    Vaadin Ltd
    • Constructor Detail

      • SlotUtils

        public SlotUtils()
    • Method Detail

      • getElementsInSlot

        public static Stream<Element> getElementsInSlot​(HasElement parent,
                                                        String slot)
        Gets all the child elements of the parent that are in the specified slot.
        Parameters:
        parent - the component to get children from, not null
        slot - the name of the slot inside the parent, not null
        Returns:
        the child elements of the parent that are inside the slot
      • clearSlot

        public static void clearSlot​(HasElement parent,
                                     String slot)
        Removes every child element of the parent that are in the specified slot.
        Parameters:
        parent - the component whose slot to clear
        slot - the name of the slot to clear
      • getChildInSlot

        public static Component getChildInSlot​(HasElement parent,
                                               String slot)
        Gets the first child component of the parent that is in the specified slot.
        Parameters:
        parent - the component to get child from, not null
        slot - the name of the slot inside the parent, not null
        Returns:
        a child component of the parent in the specified slot, or null if none is found