Class Details
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.details.Details
- All Implemented Interfaces:
AttachNotifier
,DetachNotifier
,HasComponents
,HasElement
,HasEnabled
,HasSize
,HasStyle
,HasTheme
,HasThemeVariant<DetailsVariant>
,HasTooltip
,Serializable
- Direct Known Subclasses:
AccordionPanel
@Tag("vaadin-details")
@NpmPackage(value="@vaadin/polymer-legacy-adapter",version="24.3.22") @NpmPackage(value="@vaadin/details",version="24.3.22")
@JsModule("@vaadin/polymer-legacy-adapter/style-modules.js") @JsModule("@vaadin/details/src/vaadin-details.js")
public class Details
extends Component
implements HasComponents, HasSize, HasThemeVariant<DetailsVariant>, HasTooltip
Details is an expandable panel for showing and hiding content from the user
to make the UI less crowded. Details consists of a summary and a content
area.
The Summary is the part that is always visible, and typically describes the contents, for example, with a title. Clicking on the summary toggles the content area’s visibility. The summary supports rich content and can contain any component. This can be utilized for example to indicate the status of the corresponding content.
The content area is the collapsible part of Details. It can contain any component. When the content area is collapsed, the content is invisible and inaccessible by keyboard or screen reader.
- Author:
- Vaadin Ltd
- See Also:
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionDetails()
Initializes a new Details component.Initializes a new Details using the provided summary.Initializes a new Details using the provided summary and content.Initializes a new Details using the provided summary and content components.Initializes a new Details using the provided summary.Initializes a new Details using the provided summary and content.Initializes a new Details using the provided summary and content components. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the given text to the content sectionvoid
add
(Collection<Component> components) Adds components to the content sectionvoid
addComponentAtIndex
(int index, Component component) Adds the given component to the content section at the specific index.void
addContent
(Component... components) Deprecated.Adds a listener to get notified when the opened state of the component changes.protected Component
Creates the summary container component.Returns the content components which were added viaHasComponents.add(Component...)
Returns summary component which was set viasetSummary(Component)
orsetSummaryText(String)
boolean
isOpened()
void
remove
(Collection<Component> components) Removes specified components from the content sectionvoid
Removes all components from the content sectionvoid
setContent
(Component content) Deprecated.since v24.2, useremoveAll()
andHasComponents.add(Component...)
instead.void
setOpened
(boolean opened) True if the details are opened and the content is displayedvoid
setSummary
(Component summary) Sets the component summaryvoid
setSummaryText
(String summary) Creates a text wrapper and sets a summary viasetSummary(Component)
Methods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, 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, setVisible
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListener
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
Methods inherited from interface com.vaadin.flow.component.HasComponents
add, addComponentAsFirst, remove
Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
Methods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabled
Methods 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, setWidthFull
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
Methods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeName
Methods inherited from interface com.vaadin.flow.component.shared.HasThemeVariant
addThemeVariants, removeThemeVariants
Methods inherited from interface com.vaadin.flow.component.shared.HasTooltip
getTooltip, setTooltipText
-
Constructor Details
-
Details
public Details()Initializes a new Details component. -
Details
Initializes a new Details using the provided summary.- Parameters:
summary
- the summary component to set.- See Also:
-
Details
Initializes a new Details using the provided summary.- Parameters:
summary
- the summary component to set.- See Also:
-
Details
Initializes a new Details using the provided summary and content.- Parameters:
summary
- the summary text to set.content
- the content component to add.- See Also:
-
Details
Initializes a new Details using the provided summary and content.- Parameters:
summary
- the summary component to set.content
- the content component to add.- See Also:
-
Details
Initializes a new Details using the provided summary and content components.- Parameters:
summary
- the summary text to set.components
- the content components to add.- See Also:
-
Details
Initializes a new Details using the provided summary and content components.- Parameters:
summary
- the summary component to set.components
- the content components to add.- See Also:
-
-
Method Details
-
createSummaryContainer
Creates the summary container component.- Returns:
- the summary container
-
setSummary
Sets the component summary- Parameters:
summary
- the summary component to set, ornull
to remove any previously set summary- See Also:
-
getSummary
Returns summary component which was set viasetSummary(Component)
orsetSummaryText(String)
- Returns:
- the summary component,
null
if nothing was set
-
setSummaryText
Creates a text wrapper and sets a summary viasetSummary(Component)
-
getSummaryText
- Returns:
- summary section content as string (empty string if nothing was set)
-
setContent
Deprecated.since v24.2, useremoveAll()
andHasComponents.add(Component...)
instead.Sets the component content- Parameters:
content
- the content of the component to set, ornull
to remove any previously set content- See Also:
-
addContent
Deprecated.since v24.2, useHasComponents.add(Component...)
instead.Adds components to the content section- Parameters:
components
- the components to add- See Also:
-
add
Adds components to the content section- Specified by:
add
in interfaceHasComponents
- Parameters:
components
- the components to add- See Also:
-
add
Adds the given text to the content section- Specified by:
add
in interfaceHasComponents
- Parameters:
text
- the text to add, not null- See Also:
-
remove
Removes specified components from the content section- Specified by:
remove
in interfaceHasComponents
- Parameters:
components
- the components to remove
-
removeAll
public void removeAll()Removes all components from the content section- Specified by:
removeAll
in interfaceHasComponents
-
addComponentAtIndex
Adds the given component to the content section 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 the content section of this one.
- Specified by:
addComponentAtIndex
in 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
-
getContent
Returns the content components which were added viaHasComponents.add(Component...)
- Returns:
- the child components of the content section
-
isOpened
- Returns:
- whether details are expanded or collapsed
-
setOpened
public void setOpened(boolean opened) True if the details are opened and the content is displayed
- Parameters:
opened
- the boolean value to set
-
addOpenedChangeListener
public Registration addOpenedChangeListener(ComponentEventListener<Details.OpenedChangeEvent> listener) Adds a listener to get notified when the opened state of the component changes.- Parameters:
listener
- the listener- Returns:
- a
Registration
for removing the event listener
-
HasComponents.add(Component...)
instead.