Package com.vaadin.flow.component.card
Class Card
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.card.Card
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasAriaLabel,com.vaadin.flow.component.HasComponents,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,com.vaadin.flow.component.HasTheme,com.vaadin.flow.component.shared.HasThemeVariant<CardVariant>,Serializable
@Tag("vaadin-card")
@NpmPackage(value="@vaadin/card",
version="25.0.0-alpha20")
@JsModule("@vaadin/card/src/vaadin-card.js")
public class Card
extends com.vaadin.flow.component.Component
implements com.vaadin.flow.component.HasSize, com.vaadin.flow.component.shared.HasThemeVariant<CardVariant>, com.vaadin.flow.component.HasComponents, com.vaadin.flow.component.HasAriaLabel
Card is a visual content container for creating a card-based layout.
- Author:
- Vaadin Ltd
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(Collection<com.vaadin.flow.component.Component> components) voidaddComponentAtIndex(int index, com.vaadin.flow.component.Component component) voidaddToFooter(com.vaadin.flow.component.Component... footerComponent) Adds components to the card's footer slot.Gets the ARIA role attribute of the card.Stream<com.vaadin.flow.component.Component>com.vaadin.flow.component.Component[]Gets all components added to the card's footer.com.vaadin.flow.component.ComponentGets the current header component.com.vaadin.flow.component.ComponentGets the current header prefix component.com.vaadin.flow.component.ComponentGets the current header suffix component.com.vaadin.flow.component.ComponentgetMedia()Gets the current media component.com.vaadin.flow.component.ComponentGets the current subtitle component.com.vaadin.flow.component.ComponentgetTitle()Gets the current title component set usingsetTitle(Component).Gets the value of thecardTitleproperty.voidremove(Collection<com.vaadin.flow.component.Component> components) voidvoidsetAriaRole(String role) Sets the ARIA role attribute on the card.voidsetHeader(com.vaadin.flow.component.Component header) Sets the component used as the card's header.voidsetHeaderPrefix(com.vaadin.flow.component.Component headerPrefix) Sets a component to the header prefix slot, displayed before the header content.voidsetHeaderSuffix(com.vaadin.flow.component.Component headerSuffix) Sets a component to the header suffix slot, displayed after the header content.voidsetMedia(com.vaadin.flow.component.Component media) Sets the component used as the card's media.voidsetSubtitle(com.vaadin.flow.component.Component subtitle) Sets the component used as the card's subtitle.voidsetTitle(com.vaadin.flow.component.Component title) Sets 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, onAttach, 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, setThemeVariant, setThemeVariants, setThemeVariants
-
Constructor Details
-
Card
public Card()
-
-
Method Details
-
setMedia
public void setMedia(com.vaadin.flow.component.Component media) 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
public com.vaadin.flow.component.Component 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
public void setTitle(com.vaadin.flow.component.Component title) 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
public com.vaadin.flow.component.Component getTitle()Gets the current title component set usingsetTitle(Component).- Returns:
- the title component, or
nullif none is set
-
setSubtitle
public void setSubtitle(com.vaadin.flow.component.Component subtitle) 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
public com.vaadin.flow.component.Component getSubtitle()Gets the current subtitle component.- Returns:
- the subtitle component, or
nullif none is set
-
setHeader
public void setHeader(com.vaadin.flow.component.Component header) 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
public com.vaadin.flow.component.Component getHeader()Gets the current header component.- Returns:
- the header component, or
nullif none is set
-
setHeaderPrefix
public void setHeaderPrefix(com.vaadin.flow.component.Component headerPrefix) 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
public com.vaadin.flow.component.Component getHeaderPrefix()Gets the current header prefix component.- Returns:
- the header prefix component, or
nullif none is set
-
setHeaderSuffix
public void setHeaderSuffix(com.vaadin.flow.component.Component headerSuffix) 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
public com.vaadin.flow.component.Component getHeaderSuffix()Gets the current header suffix component.- Returns:
- the header suffix component, or
nullif none is set
-
getChildren
- Overrides:
getChildrenin classcom.vaadin.flow.component.Component
-
add
- Specified by:
addin interfacecom.vaadin.flow.component.HasComponents
-
remove
- Specified by:
removein interfacecom.vaadin.flow.component.HasComponents
-
removeAll
public void removeAll()- Specified by:
removeAllin interfacecom.vaadin.flow.component.HasComponents
-
addComponentAtIndex
public void addComponentAtIndex(int index, com.vaadin.flow.component.Component component) - Specified by:
addComponentAtIndexin interfacecom.vaadin.flow.component.HasComponents
-
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
-