Skip to content

CustomTabOptionsBuilder

Fluent builder for constructing CustomTabOptions instances with runtime feature gating.

Overview

CustomTabOptionsBuilder provides a chainable API for configuring CustomTabOptions. Each With* method returns the same builder instance for fluent chaining. Call Build() to create the final CustomTabOptions object.

Example

var options = new CustomTabOptionsBuilder()
    .WithColorScheme(ColorScheme.Dark)
    .WithTitleShowed(true)
    .WithUrlHidingEnabled(true)
    .Build();

_customTab.LaunchUrlWithSession("https://example.com", options);

Methods

WithTitleShowed

public CustomTabOptionsBuilder WithTitleShowed(
    bool titleShowed
)

Sets whether the page title is shown in the toolbar.

Parameters

  • titleShowed (bool): true to show the page title; otherwise false.

Returns

  • The current CustomTabOptionsBuilder instance.

WithShareState

public CustomTabOptionsBuilder WithShareState(
    ShareState shareState
)

Sets share button visibility.

Parameters

  • shareState (ShareState): The desired share state.

Returns

  • The current CustomTabOptionsBuilder instance.

WithUrlHidingEnabled

public CustomTabOptionsBuilder WithUrlHidingEnabled(
    bool urlHidingEnabled
)

Sets whether the URL bar hides while scrolling.

Parameters

  • urlHidingEnabled (bool): true to hide the URL bar.

Returns

  • The current CustomTabOptionsBuilder instance.

WithBackgroundInteractionEnabled

public CustomTabOptionsBuilder WithBackgroundInteractionEnabled(
    bool backgroundInteractionEnabled
)

Sets whether interaction with the app behind the tab is allowed in partial mode.

Parameters

  • backgroundInteractionEnabled (bool): true to allow background interaction.

Returns

  • The current CustomTabOptionsBuilder instance.

WithBookmarksButtonEnabled

public CustomTabOptionsBuilder WithBookmarksButtonEnabled(
    bool bookmarksButtonEnabled
)

Sets whether the bookmarks button is shown.

Parameters

  • bookmarksButtonEnabled (bool): true to show the bookmarks button.

Returns

  • The current CustomTabOptionsBuilder instance.

WithDownloadButtonEnabled

public CustomTabOptionsBuilder WithDownloadButtonEnabled(
    bool downloadButtonEnabled
)

Sets whether the download button is shown.

Parameters

  • downloadButtonEnabled (bool): true to show the download button.

Returns

  • The current CustomTabOptionsBuilder instance.

WithEphemeralBrowsingEnabled

public CustomTabOptionsBuilder WithEphemeralBrowsingEnabled(
    bool ephemeralBrowsingEnabled
)

Sets whether ephemeral browsing is enabled.

Parameters

  • ephemeralBrowsingEnabled (bool): true to enable ephemeral browsing.

Returns

  • The current CustomTabOptionsBuilder instance.

WithColorScheme

public CustomTabOptionsBuilder WithColorScheme(
    ColorScheme colorScheme
)

Sets the color scheme for the Custom Tab.

Parameters

  • colorScheme (ColorScheme): The desired color scheme.

Returns

  • The current CustomTabOptionsBuilder instance.

WithLightColorSchemeOptions

public CustomTabOptionsBuilder WithLightColorSchemeOptions(
    ColorSchemeOptions lightCustomTabColorSchemeOptions
)

Sets color options used in light mode.

Parameters

  • lightCustomTabColorSchemeOptions (ColorSchemeOptions): Light mode color options.

Returns

  • The current CustomTabOptionsBuilder instance.

WithDarkColorSchemeOptions

public CustomTabOptionsBuilder WithDarkColorSchemeOptions(
    ColorSchemeOptions darkCustomTabColorSchemeOptions
)

Sets color options used in dark mode.

Parameters

  • darkCustomTabColorSchemeOptions (ColorSchemeOptions): Dark mode color options.

Returns

  • The current CustomTabOptionsBuilder instance.

WithDefaultColorSchemeOptions

public CustomTabOptionsBuilder WithDefaultColorSchemeOptions(
    ColorSchemeOptions defaultCustomTabColorSchemeOptions
)

Sets fallback color options used when mode-specific options are not applied.

Parameters

  • defaultCustomTabColorSchemeOptions (ColorSchemeOptions): Fallback color options.

Returns

  • The current CustomTabOptionsBuilder instance.

WithInitialHeightPx

public CustomTabOptionsBuilder WithInitialHeightPx(
    int initialHeightPx
)

Sets the initial height in pixels for bottom-sheet mode.

Parameters

  • initialHeightPx (int): Initial height in pixels.

Returns

  • The current CustomTabOptionsBuilder instance.

WithInitialWidthPx

public CustomTabOptionsBuilder WithInitialWidthPx(
    int initialWidthPx
)

Sets the initial width in pixels for side-sheet mode.

Parameters

  • initialWidthPx (int): Initial width in pixels.

Returns

  • The current CustomTabOptionsBuilder instance.

WithHeightResizeBehavior

public CustomTabOptionsBuilder WithHeightResizeBehavior(
    HeightResizeBehavior heightResizeBehavior
)

Sets resize behavior for bottom-sheet mode.

Parameters

  • heightResizeBehavior (HeightResizeBehavior): The desired resize behavior.

Returns

  • The current CustomTabOptionsBuilder instance.

WithToolbarCornerRadiusDp

public CustomTabOptionsBuilder WithToolbarCornerRadiusDp(
    int toolbarCornerRadiusDp
)

Sets toolbar corner radius in density-independent pixels (dp) for bottom-sheet mode.

Parameters

  • toolbarCornerRadiusDp (int): Corner radius in dp. Maximum supported value is 16.

Returns

  • The current CustomTabOptionsBuilder instance.

WithOpenAnimation

public CustomTabOptionsBuilder WithOpenAnimation(
    CustomTabAnimation openAnimation
)

Sets the animation used when opening the tab.

Parameters

  • openAnimation (CustomTabAnimation): Animation pair for open transition.

Returns

  • The current CustomTabOptionsBuilder instance.

WithCloseAnimation

public CustomTabOptionsBuilder WithCloseAnimation(
    CustomTabAnimation closeAnimation
)

Sets the animation used when closing the tab.

Parameters

  • closeAnimation (CustomTabAnimation): Animation pair for close transition.

Returns

  • The current CustomTabOptionsBuilder instance.

WithShareIdentityEnabled

public CustomTabOptionsBuilder WithShareIdentityEnabled(
    bool shareIdentityEnabled
)

Sets whether app-specific history sharing is enabled.

Parameters

  • shareIdentityEnabled (bool): true to enable app-specific history.

Returns

  • The current CustomTabOptionsBuilder instance.

WithSendToExternalDefaultHandlerEnabled

public CustomTabOptionsBuilder WithSendToExternalDefaultHandlerEnabled(
    bool sendToExternalDefaultHandlerEnabled
)

Sets whether matching URLs are routed to external default handlers.

Parameters

  • sendToExternalDefaultHandlerEnabled (bool): true to route matching URLs to external apps.

Returns

  • The current CustomTabOptionsBuilder instance.

WithSideSheetBreakingPointDp

public CustomTabOptionsBuilder WithSideSheetBreakingPointDp(
    int sideSheetBreakingPointDp
)

Sets the screen width breakpoint in dp for switching to side-sheet mode.

Parameters

  • sideSheetBreakingPointDp (int): Breakpoint width in dp.

Returns

  • The current CustomTabOptionsBuilder instance.

WithSideSheetDecorationType

public CustomTabOptionsBuilder WithSideSheetDecorationType(
    SideSheetDecoration sideSheetDecoration
)

Sets side-sheet decoration style.

Parameters

  • sideSheetDecoration (SideSheetDecoration): The desired decoration style.

Returns

  • The current CustomTabOptionsBuilder instance.

WithSideSheetMaximizationEnabled

public CustomTabOptionsBuilder WithSideSheetMaximizationEnabled(
    bool sideSheetMaximizationEnabled
)

Sets whether side-sheet maximization is enabled.

Parameters

  • sideSheetMaximizationEnabled (bool): true to allow maximization.

Returns

  • The current CustomTabOptionsBuilder instance.

WithSideSheetPosition

public CustomTabOptionsBuilder WithSideSheetPosition(
    SideSheetPosition sideSheetPosition
)

Sets side-sheet position.

Parameters

  • sideSheetPosition (SideSheetPosition): The desired side-sheet position.

Returns

  • The current CustomTabOptionsBuilder instance.

WithSideSheetRoundedCornersPosition

public CustomTabOptionsBuilder WithSideSheetRoundedCornersPosition(
    SideSheetRoundedCornersPosition sheetRoundedCornersPosition
)

Sets which side-sheet corners are rounded.

Parameters

  • sheetRoundedCornersPosition (SideSheetRoundedCornersPosition): Rounded corner position rule.

Returns

  • The current CustomTabOptionsBuilder instance.

WithCloseButtonPosition

public CustomTabOptionsBuilder WithCloseButtonPosition(
    CloseButtonPosition closeButtonPosition
)

Sets close button position.

Parameters

  • closeButtonPosition (CloseButtonPosition): The desired close button position.

Returns

  • The current CustomTabOptionsBuilder instance.

WithCloseButtonIcon

public CustomTabOptionsBuilder WithCloseButtonIcon(
    CloseButtonIcon closeButtonIcon
)

Sets close button icon style.

Parameters

  • closeButtonIcon (CloseButtonIcon): The desired close button icon.

Returns

  • The current CustomTabOptionsBuilder instance.

Build

public CustomTabOptions Build()

Builds and returns a CustomTabOptions instance from the current builder state.

Returns

  • A new CustomTabOptions object with all configured properties.
  • Unset properties remain null.