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<com.vaadin.flow.dom.Element> getElementsInSlot​(com.vaadin.flow.component.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​(com.vaadin.flow.component.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 com.vaadin.flow.component.Component getChildInSlot​(com.vaadin.flow.component.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