Class ShareContent

java.lang.Object
com.vaadin.flow.component.webshare.ShareContent
All Implemented Interfaces:
Serializable

public final class ShareContent extends Object implements Serializable
Payload for WebShareBinding.share(com.vaadin.flow.component.webshare.ShareContent). Any combination of title, text, and url can be set; the Web Share API requires at least one of them to be present.

Use the static factory:


 WebShare.onClick(button).share(ShareContent.create().title("Hello")
         .text("World").url("https://vaadin.com"));
 
Since:
25.2
See Also:
  • Method Details

    • create

      public static ShareContent create()
      Creates a new empty content builder.
      Returns:
      a new builder
    • title

      public ShareContent title(String literal)
      Sets the title of the share payload.
      Parameters:
      literal - the value, not null
      Returns:
      this builder
    • title

      public <C extends Component & HasValue<?, String>> ShareContent title(C source)
      Sets the title of the share payload, taken from the value property of the given component (typically an input field). The value is read on the client when the trigger fires.
      Type Parameters:
      C - component type implementing HasValue<?, String>
      Parameters:
      source - the component whose value property should be read, not null
      Returns:
      this builder
    • text

      public ShareContent text(String literal)
      Sets the free-form text of the share payload.
      Parameters:
      literal - the value, not null
      Returns:
      this builder
    • text

      public <C extends Component & HasValue<?, String>> ShareContent text(C source)
      Sets the free-form text of the share payload, taken from the value property of the given component. The value is read on the client when the trigger fires.
      Type Parameters:
      C - component type implementing HasValue<?, String>
      Parameters:
      source - the component whose value property should be read, not null
      Returns:
      this builder
    • url

      public ShareContent url(String literal)
      Sets the URL of the share payload.
      Parameters:
      literal - the value, not null
      Returns:
      this builder
    • url

      public <C extends Component & HasValue<?, String>> ShareContent url(C source)
      Sets the URL of the share payload, taken from the value property of the given component. The value is read on the client when the trigger fires.
      Type Parameters:
      C - component type implementing HasValue<?, String>
      Parameters:
      source - the component whose value property should be read, not null
      Returns:
      this builder