Skip to content

Bottom Sheet

The Bottom sheet component that shows the secondary content anchored to the bottom of the screen.

Importing

To use the bottom sheet component, first you need to register the component inside the page. You can register the component manually by importing the register function:

ts
import { register } from "@tapsioss/web-components/bottom-sheet";

register(); // Now the bottom sheet component is ready to use!
ts
import { registerBottomSheet } from "@tapsioss/web-components";

registerBottomSheet(); // Now the bottom sheet component is ready to use!

Also you can automatically register the component by importing it with the following approach:

ts
import "@tapsioss/web-components/bottom-sheet/element";

TIP

If you want to use all the component in your app, you can call registerAll at the root of your project.

ts
import { registerAll } from "@tapsioss/web-components";

registerAll(); // All the components are now available

In the React package, you can easily add the component using the following code:

ts
import { BottomSheet } from "@tapsioss/react-components";

Component Usage

html
<tapsi-bottom-sheet></tapsi-bottom-sheet>
tsx
<BottomSheet />

Properties

NameAttribute NameDescriptionTypeDefault Value
headingTitleheading-titleSets the heading title in a declarative-way.string""
headingDescriptionheading-descriptionSets the heading description in a declarative-way.string""
hasGrabberhas-grabberDetermines whether the grabber should be visible or not.booleanfalse
hasDismissButtonhas-dismiss-buttonDetermines whether the dismiss button should be visible or not.booleanfalse
hasStickyActionBarsticky-action-barDetermines whether the action bar should be sticky or not.booleanfalse
hasStickyHeadersticky-headerDetermines whether the header should be sticky or not.booleanfalse
expandableexpandableDetermines whether the bottom sheet should be expanded
by grabbing gesture.
booleanfalse
variantvariantThe variant of the bottom sheet."modal" | "inline""modal"
labellabelDefines a string value that can be used to set a label
for assistive technologies.

https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label
string""
labelledBylabelledbyIdentifies the element (or elements) that labels the element.

https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-labelledby
string""
focusTargetfocus-targetIdentifies the element that should get focused when bottom sheet opens.string""
metaData-The metadata of the bottom sheet.MetaData-
defaultSnapPoints-An array containing two snap points.
- The first snap point is either the container's scroll height
or half the window's inner height, whichever is smaller.
- The second snap point is 90% of the window's inner height.
[number, number]-
snapPoints-The snap points for bottom sheet to snap to.
Note that snap points will be sorted, no matter
how to set it.
number[]-
openopenDetermines whether the bottom sheet should be open or not.booleanfalse

Methods

NameDescriptionParameters
strictSnapToStrictly snaps to the provided or resolved snap point.Name: numberOrCallback
Type: (number | SnapToCallbackArgument)
snapToWhen given a number it'll find the closest snap point,
so you don't need to know the exact value.
Use the callback method to resolve the snap point.
Name: numberOrCallback
Type: (number | SnapToCallbackArgument)
showOpens the bottom sheet if it is not already open.
Dispatches a cancelable ShowEvent ("show").
hideCloses the bottom sheet if it is currently open.
Dispatches a cancelable HideEvent ("hide").

Slots

NameValueDescription
HEADERheaderThe slot for the action bar content.
BODYbodyThe slot for the action bar content.
ACTION_BARaction-barThe slot for the action bar content.

TIP

The value of slots are available for developer as JavaScript Variables:

ts
// Option 1
import { BottomSheetSlots } from "@tapsioss/web-components";

// Option 2
import { Slots } from "@tapsioss/web-components/bottom-sheet";
ts
// Option 1
import { BottomSheetSlots } from "@tapsioss/react-components";

// Option 2
import { Slots } from "@tapsioss/react-components/BottomSheet";

Events

NameDescriptionTypeBubblesCancelable
snappedFired when the bottom-sheet is snapped to a specific position.SnappedEvent
openingFired when the bottom-sheet starts to open.OpeningEvent
closingFired when the bottom-sheet starts to close.ClosingEvent
openedFired when the bottom-sheet has fully opened.OpenedEvent
closedFired when the bottom-sheet has fully closed.ClosedEvent
hideFired when the bottom-sheet is hidden.HideEvent
showFired when the bottom-sheet is shown.ShowEvent

TIP

Event details are available as JavaScript variables:

ts
// Option 1
import {
 SnappedEvent,
 OpeningEvent,
 ClosingEvent,
 OpenedEvent,
 ClosedEvent,
 HideEvent,
 ShowEvent
} from "@tapsioss/web-components/bottom-sheet";

// Option 2
import {
 BottomSheetSnappedEvent,
 BottomSheetOpeningEvent,
 BottomSheetClosingEvent,
 BottomSheetOpenedEvent,
 BottomSheetClosedEvent,
 BottomSheetHideEvent,
 BottomSheetShowEvent
} from "@tapsioss/web-components";

You can have access to the event name using the type property:

ts
// Option 1
element.addEventListener(SnappedEvent.type, handleSnapped);
element.addEventListener(OpeningEvent.type, handleOpening);
element.addEventListener(ClosingEvent.type, handleClosing);
element.addEventListener(OpenedEvent.type, handleOpened);
element.addEventListener(ClosedEvent.type, handleClosed);
element.addEventListener(HideEvent.type, handleHide);
element.addEventListener(ShowEvent.type, handleShow);

// Option 2
element.addEventListener(BottomSheetSnappedEvent.type, handleSnapped);
element.addEventListener(BottomSheetOpeningEvent.type, handleOpening);
element.addEventListener(BottomSheetClosingEvent.type, handleClosing);
element.addEventListener(BottomSheetOpenedEvent.type, handleOpened);
element.addEventListener(BottomSheetClosedEvent.type, handleClosed);
element.addEventListener(BottomSheetHideEvent.type, handleHide);
element.addEventListener(BottomSheetShowEvent.type, handleShow);

Created with 🧡