Class Card
- All Implemented Interfaces:
AttachNotifier,DetachNotifier,HasAriaLabel,HasComponents,HasElement,HasEnabled,HasSize,HasStyle,HasTheme,HasThemeVariant<CardVariant>,Serializable
- Author:
- Vaadin Ltd
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(Collection<Component> components) Adds the given components as children of this component.voidaddComponentAtIndex(int index, Component component) Adds the given component as child of this component at the specific index.voidaddToFooter(Component... footerComponent) Adds components to the card's footer slot.Gets the ARIA role attribute of the card.Gets the child components of this component.Gets all components added to the card's footer.Gets the current header component.Gets the current header prefix component.Gets the current header suffix component.getMedia()Gets the current media component.Gets the current subtitle component.getTitle()Gets the current title component set usingsetTitle(Component).Gets the value of thecardTitleproperty.protected voidonAttach(AttachEvent attachEvent) Called when the component is attached to a UI.voidremove(Collection<Component> components) Removes the given child components from this component.voidRemoves all contents from this component, this includes child components, text content as well as child elements that have been added directly to this component using theElementAPI.voidsetAriaRole(String role) Sets the ARIA role attribute on the card.voidSets the component used as the card's header.voidsetHeaderPrefix(Component headerPrefix) Sets a component to the header prefix slot, displayed before the header content.voidsetHeaderSuffix(Component headerSuffix) Sets a component to the header suffix slot, displayed after the header content.voidSets the component used as the card's media.voidsetSubtitle(Component subtitle) Sets the component used as the card's subtitle.voidSets the component used as the card's title.voidSets thecardTitleproperty.voidSets the title and the heading level for the title.voidsetTitleHeadingLevel(Integer titleHeadingLevel) Sets the title heading level property for the titles set usingsetTitle(String).Methods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasAriaLabel
getAriaLabel, getAriaLabelledBy, setAriaLabel, setAriaLabelledByMethods inherited from interface com.vaadin.flow.component.HasComponents
add, add, addComponentAsFirst, removeMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNameMethods inherited from interface com.vaadin.flow.component.shared.HasThemeVariant
addThemeVariants, removeThemeVariants
-
Constructor Details
-
Card
public Card()
-
-
Method Details
-
setMedia
Sets the component used as the card's media. The media slot is typically used to display an image, icon, or other visual element.Passing
nullremoves the current media component from the card.- Parameters:
media- the media component, ornullto remove
-
getMedia
Gets the current media component.- Returns:
- the media component, or
nullif none is set
-
setTitle
Sets thecardTitleproperty. If aheader componentis set, the title will not be displayed. Setting a title this way removes any title component set usingsetTitle(Component). Settingnullor empty string removes any previously setStringtitles.- Parameters:
title- the title property- See Also:
-
setTitle
Sets the title and the heading level for the title. If aheader componentis set, the title will not be displayed. Setting a title this way removes any title component set usingsetTitle(Component). Settingnullor empty title removes any previously setStringtitles.- Parameters:
title- the title propertytitleHeadingLevel- the title heading level property,- See Also:
-
setTitleHeadingLevel
Sets the title heading level property for the titles set usingsetTitle(String). The default is 2. Settingnullresets it to default. Does not affect the title components set usingsetTitle(Component).- Parameters:
titleHeadingLevel- the title heading level property,nullto remove
-
setTitle
Sets the component used as the card's title. If aheader componentis set, the title will not be displayed. This also removes any previously setStringtitles.Passing
nullremoves the current title from the card.- Parameters:
title- the title component, ornullto remove
-
getTitleAsText
Gets the value of thecardTitleproperty. Returns empty if no title is set.- Returns:
- the value of the title property
-
getTitle
Gets the current title component set usingsetTitle(Component).- Returns:
- the title component, or
nullif none is set
-
setSubtitle
Sets the component used as the card's subtitle. If aheader componentis set, the subtitle will not be displayed.Passing
nullremoves the current subtitle from the card.- Parameters:
subtitle- the subtitle component, ornullto remove
-
getSubtitle
Gets the current subtitle component.- Returns:
- the subtitle component, or
nullif none is set
-
setHeader
Sets the component used as the card's header. The header is prioritized over thetitleandsubtitlecomponents, and will be displayed instead.Passing
nullremoves the current header component from the card.- Parameters:
header- the header component, ornullto remove
-
getHeader
Gets the current header component.- Returns:
- the header component, or
nullif none is set
-
setHeaderPrefix
Sets a component to the header prefix slot, displayed before the header content.Passing
nullremoves any existing prefix from the header.- Parameters:
headerPrefix- the header prefix component, ornullto remove
-
getHeaderPrefix
Gets the current header prefix component.- Returns:
- the header prefix component, or
nullif none is set
-
setHeaderSuffix
Sets a component to the header suffix slot, displayed after the header content. Commonly used for decorative icons or custom suffixes.Passing
nullremoves any existing suffix from the header.- Parameters:
headerSuffix- the header suffix component, ornullto remove
-
getHeaderSuffix
Gets the current header suffix component.- Returns:
- the header suffix component, or
nullif none is set
-
getChildren
Description copied from class:ComponentGets the child components of this component.The default implementation finds child components by traversing each child
Elementtree.If the component is injected to a PolymerTemplate using the
@Idannotation the getChildren method will only return children added from the server side and will not return any children declared in the template file.- Overrides:
getChildrenin classComponent- Returns:
- the child components of this component
- See Also:
-
add
Description copied from interface:HasComponentsAdds the given components as children of this component.In case any of the specified components has already been added to another parent, it will be removed from there and added to this one.
- Specified by:
addin interfaceHasComponents- Parameters:
components- the components to add
-
remove
Description copied from interface:HasComponentsRemoves the given child components from this component.- Specified by:
removein interfaceHasComponents- Parameters:
components- the components to remove
-
removeAll
public void removeAll()Description copied from interface:HasComponentsRemoves all contents from this component, this includes child components, text content as well as child elements that have been added directly to this component using theElementAPI. it also removes the children that were added only at the client-side.- Specified by:
removeAllin interfaceHasComponents
-
addComponentAtIndex
Description copied from interface:HasComponentsAdds the given component as child of this component at the specific index.In case the specified component has already been added to another parent, it will be removed from there and added to this one.
- Specified by:
addComponentAtIndexin interfaceHasComponents- Parameters:
index- the index, where the component will be added. The index must be non-negative and may not exceed the children countcomponent- the component to add, value should not be null
-
setAriaRole
Sets the ARIA role attribute on the card.- Parameters:
role- the ARIA role, ornullto clear
-
getAriaRole
Gets the ARIA role attribute of the card.- Returns:
- an optional ARIA role of the card if no ARIA role has been set
-
onAttach
Description copied from class:ComponentCalled when the component is attached to a UI.This method is invoked before the
Make sure to callAttachEventis fired for the component.super.onAttachwhen overriding this method.
-