Package com.vaadin.flow.component.shared
Class SlotUtils
java.lang.Object
com.vaadin.flow.component.shared.SlotUtils
Util methods for handling child elements inside slots.
- Author:
- Vaadin Ltd
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddToSlot(HasElement parent, String slot, Component... components) Adds components to the specified slot in the parent component.static voidaddToSlot(HasElement parent, String slot, Element... elements) Adds elements to the specified slot in the parent component.static voidclearSlot(HasElement parent, String slot) Removes every child element of the parent that are in the specified slot.static ComponentgetChildInSlot(HasElement parent, String slot) Gets the first child component of the parent that is in the specified slot.getElementsInSlot(HasElement parent, String slot) Gets all the child elements of the parent that are in the specified slot.static voidsetSlot(HasElement parent, String slot, Component... components) Clears the specific slot in the parent component and adds components to it.static voidsetSlot(HasElement parent, String slot, Element... elements) Clears the specific slot in the parent component and adds elements to it.
-
Constructor Details
-
SlotUtils
public SlotUtils()
-
-
Method Details
-
getElementsInSlot
Gets all the child elements of the parent that are in the specified slot.- Parameters:
parent- the component to get children from, notnullslot- the name of the slot inside the parent, notnull- Returns:
- the child elements of the parent that are inside the slot
-
clearSlot
Removes every child element of the parent that are in the specified slot.- Parameters:
parent- the component whose slot to clearslot- the name of the slot to clear
-
getChildInSlot
Gets the first child component of the parent that is in the specified slot.- Parameters:
parent- the component to get child from, notnullslot- the name of the slot inside the parent, notnull- Returns:
- a child component of the parent in the specified slot, or
nullif none is found
-
addToSlot
Adds components to the specified slot in the parent component.- Parameters:
parent- the parent component to add the components to, notnullslot- the name of the slot inside the parent, notnullcomponents- components to add to the specified slot.- Throws:
IllegalArgumentException- if any of the components is aTextcomponent.NullPointerException- if the components array is null.
-
addToSlot
Adds elements to the specified slot in the parent component.- Parameters:
parent- the parent component to add the elements to, notnullslot- the name of the slot inside the parent, notnullelements- elements to add to the specified slot.- Throws:
NullPointerException- if the elements array is null.
-
setSlot
Clears the specific slot in the parent component and adds components to it.- Parameters:
parent- the parent component to add the components to, notnullslot- the name of the slot inside the parent, notnullcomponents- components to add to the specified slot.- Throws:
NullPointerException- if the components array is null.
-
setSlot
Clears the specific slot in the parent component and adds elements to it.- Parameters:
parent- the parent component to add the elements to, notnullslot- the name of the slot inside the parent, notnullelements- elements to add to the specified slot.- Throws:
NullPointerException- if the elements array is null.
-