Package com.vaadin.flow.component
Interface HasStyle
- All Superinterfaces:
HasElement
,Serializable
- All Known Subinterfaces:
FlexComponent
,InputField<E,
V>
- All Known Implementing Classes:
AbstractCompositeField
,AbstractField
,AbstractIcon
,AbstractLogin
,AbstractNumberField
,AbstractRouteNotFoundError
,AbstractSinglePropertyField
,Accordion
,AccordionPanel
,Anchor
,AppLayout
,Article
,Aside
,Avatar
,AvatarGroup
,BigDecimalField
,Board
,Button
,Chart
,Checkbox
,CheckboxGroup
,CollaborationAvatarGroup
,CollaborationMessageInput
,CollaborationMessageList
,ComboBox
,ComboBoxBase
,Component
,Composite
,ConfirmDialog
,ContextMenu
,ContextMenuBase
,CookieConsent
,Crud
,CrudGrid
,CustomField
,DatePicker
,DateTimePicker
,DescriptionList
,DescriptionList.Description
,DescriptionList.Term
,Details
,Dialog
,Div
,DrawerToggle
,EmailField
,Emphasis
,FlexLayout
,FontIcon
,Footer
,FormLayout
,FormLayout.FormItem
,Grid
,Grid.Column
,GridContextMenu
,GridMenuItem
,GridPro
,GridPro.EditColumn
,GridSelectionColumn
,H1
,H2
,H3
,H4
,H5
,H6
,Header
,HorizontalLayout
,Hr
,Html
,HtmlComponent
,HtmlContainer
,HtmlObject
,Icon
,IFrame
,Image
,Input
,IntegerField
,InternalServerError
,Label
,ListBox
,ListBoxBase
,ListItem
,LitTemplate
,LoginForm
,LoginOverlay
,Main
,Map
,MapBase
,MenuBar
,MenuItem
,MenuItemBase
,MessageInput
,MessageList
,MultiSelectComboBox
,MultiSelectListBox
,NativeButton
,NativeDetails
,NativeDetails.Summary
,NativeLabel
,Nav
,Notification
,NumberField
,OrderedList
,Paragraph
,Param
,PasswordField
,Pre
,ProgressBar
,RadioButtonGroup
,RangeInput
,ReactAdapterComponent
,RichTextEditor
,RouteAccessDeniedError
,RouteNotFoundError
,RouterLink
,Row
,Scroller
,Section
,Select
,SideNav
,SideNavItem
,Span
,SplitLayout
,Svg
,SvgIcon
,Tab
,Tabs
,TabSheet
,Text
,TextArea
,TextField
,TextFieldBase
,TimePicker
,TreeGrid
,UI
,UI.ClientViewPlaceholder
,UnorderedList
,Upload
,VerticalLayout
,VirtualList
,WebComponentUI
,WebComponentWrapper
Represents
Component
which has class attribute and inline styles.
Implementation of HasElement.getElement()
should return HTML element or web
component that supports inline
style attribute.
- Since:
- 1.0
- Author:
- Vaadin Ltd
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
addClassName
(String className) Adds a CSS class name to this component.default void
addClassNames
(String... classNames) Adds one or more CSS class names to this component.default String
Gets the CSS class names for this component.default ClassList
Gets the set of CSS class names used for this element.default Style
getStyle()
Gets the style instance for managing inline styles for the element of this component.default boolean
hasClassName
(String className) Checks if the component has the given class name.default boolean
removeClassName
(String className) Removes a CSS class name from this component.default void
removeClassNames
(String... classNames) Removes one or more CSS class names from component.default void
setClassName
(String className) Sets the CSS class names of this component.default void
setClassName
(String className, boolean set) Sets or removes the given class name for this component.Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
-
Method Details
-
addClassName
Adds a CSS class name to this component.- Parameters:
className
- the CSS class name to add, notnull
-
removeClassName
Removes a CSS class name from this component.- Parameters:
className
- the CSS class name to remove, notnull
- Returns:
true
if the class name was removed,false
if the class list didn't contain the class name
-
setClassName
Sets the CSS class names of this component. This method overwrites any previous set class names.- Parameters:
className
- a space-separated string of class names to set, ornull
to remove all class names
-
getClassName
Gets the CSS class names for this component.- Returns:
- a space-separated string of class names, or
null
if there are no class names
-
getClassNames
Gets the set of CSS class names used for this element. The returned set can be modified to add or remove class names. The contents of the set is also reflected in the value of theclass
attribute.Despite the name implying a list being returned, the return type is actually a
Set
since the in-browser return value behaves like aSet
in Java.- Returns:
- a list of class names, never
null
- See Also:
-
setClassName
Sets or removes the given class name for this component.- Parameters:
className
- the class name to set or remove, notnull
set
-true
to set the class name,false
to remove it
-
hasClassName
Checks if the component has the given class name.- Parameters:
className
- the class name to check for- Returns:
true
if the component has the given class name,false
otherwise
-
getStyle
Gets the style instance for managing inline styles for the element of this component.- Returns:
- the style object for the element, not
null
-
addClassNames
Adds one or more CSS class names to this component. Multiple class names can be specified by using spaces or by giving multiple parameters.- Parameters:
classNames
- the CSS class name or class names to be added to the component
-
removeClassNames
Removes one or more CSS class names from component. Multiple class names can be specified by using spaces or by giving multiple parameters.- Parameters:
classNames
- the CSS class name or class names to be removed from the component
-