Skip to content
GitHub11 stars

A panel that slides in from the edge of the screen.

<DrawerRoot SwipeDirection="DrawerSwipeDirection.Right">
    <DrawerTrigger class="drawer-button">
        Open drawer

Usage guidelines

  • Drawer extends Dialog: It adds gestures, snap points and indent effects. If you don't need these, use Dialog instead. A panel that slides in from the edge of the screen and doesn't need gestures is a positioned Dialog.

Anatomy

Import the primitives and assemble the parts:

@using Blazix.Primitives

<DrawerProvider>
    <DrawerIndentBackground />
    <DrawerIndent>
        <DrawerRoot>
            <DrawerTrigger />
            <DrawerSwipeArea />
            <DrawerPortal>
                <DrawerBackdrop />
                <DrawerViewport>
                    <DrawerPopup>
                        <DrawerContent>
                            <DrawerTitle />
                            <DrawerDescription />
                            <DrawerClose />
                        </DrawerContent>
                    </DrawerPopup>
                </DrawerViewport>
            </DrawerPortal>
        </DrawerRoot>
    </DrawerIndent>
</DrawerProvider>

API Reference

DrawerRoot

Doesn't render its own HTML element.

ParameterTypeDefault
SwipeDirection DrawerSwipeDirection DrawerSwipeDirection.Down
SnapPoints IReadOnlyList<DrawerSnapPoint>? -
SnapPoint DrawerSnapPoint? -
SnapPointChanged

Called with the new value when SnapPoint changes, for @bind-SnapPoint.

EventCallback<DrawerSnapPoint?> -
OnSnapPointChange EventCallback<ValueChangeEventArgs<DrawerSnapPoint?>> -
DefaultSnapPoint DrawerSnapPoint? -
SnapToSequentialPoints bool false
Modal PopupModal PopupModal.True
DisablePointerDismissal bool false
Open bool false
OpenChanged

Called with the new value when Open changes, for @bind-Open.

EventCallback<bool> -
OnOpenChange EventCallback<OpenChangeEventArgs> -
OnOpenChangeComplete EventCallback<bool> -
Handle PopupHandle? -
ContentTemplate RenderFragment<object?>? -
ChildContent

The part's content.

RenderFragment? -

DrawerProvider

Doesn't render its own HTML element.

ParameterTypeDefault
ChildContent

The part's content.

RenderFragment? -

DrawerTrigger

Renders a <button> element.

ParameterTypeDefault
Disabled

Whether the component should ignore user interaction.

bool false
Handle PopupHandle? -
Payload object? -
NativeButton bool? -
Render RenderFragment<PopupTriggerRenderProps>? -
ChildContent

The part's content.

RenderFragment? -

Other attributes are passed to the element it renders.

AttributeType
data-popup-open

Present when the corresponding dialog is open.

-
data-disabled

Present when the trigger is disabled.

-

DrawerPortal

Doesn't render its own HTML element.

ParameterTypeDefault
KeepMounted bool false
ChildContent

The part's content.

RenderFragment? -

DrawerBackdrop

Renders a <div> element.

ParameterTypeDefault
ForceRender bool false
Render RenderFragment<PopupRenderProps>? -
ChildContent

The part's content.

RenderFragment? -

Other attributes are passed to the element it renders.

AttributeType
data-open

Present when the drawer is open.

-
data-closed

Present when the drawer is closed.

-
data-starting-style

Present when the drawer begins animating in.

-
data-ending-style

Present when the drawer is animating out.

-
CSS variableType
--drawer-swipe-progress

The swipe progress of the drawer gesture.

number

DrawerPopup

Renders a <div> element.

ParameterTypeDefault
KeepMounted bool false
InitialFocus string? -
FinalFocus string? -
PositionerAttributes IReadOnlyDictionary<string, object>? -
Render RenderFragment<DialogPopupRenderProps>? -
ChildContent

The part's content.

RenderFragment? -

Other attributes are passed to the element it renders.

AttributeType
data-open

Present when the drawer is open.

-
data-closed

Present when the drawer is closed.

-
data-expanded

Present when the drawer is at the expanded (full-height) snap point.

-
data-nested-drawer-open

Present when a nested drawer is open.

-
data-nested-drawer-swiping

Present when a nested drawer is being swiped.

-
data-swipe-direction

Indicates the swipe direction.

'up' | 'down' | 'left' | 'right'
data-swipe-dismiss

Present when the drawer is dismissed by swiping.

-
data-swiping

Present when the drawer is being swiped.

-
data-starting-style

Present when the drawer begins animating in.

-
data-ending-style

Present when the drawer is animating out.

-
CSS variableType
--drawer-frontmost-height

The height of the frontmost open drawer in the current nested drawer stack.

CSS
--drawer-height

The height of the drawer popup.

CSS
--drawer-snap-point-offset

The snap point offset used for translating the drawer.

CSS
--drawer-swipe-movement-x

The swipe movement on the X axis.

CSS
--drawer-swipe-movement-y

The swipe movement on the Y axis.

CSS
--drawer-swipe-strength

A scalar (0.1-1) used to scale the swipe release transition duration in CSS.

number
--nested-drawers

The number of nested drawers that are currently open.

number

DrawerContent

Renders a <div> element.

ParameterTypeDefault
Render RenderFragment<PartRenderProps>? -
ChildContent

The part's content.

RenderFragment? -

Other attributes are passed to the element it renders.

DrawerTitle

Renders a <h2> element.

ParameterTypeDefault
Render RenderFragment<PopupRenderProps>? -
ChildContent

The part's content.

RenderFragment? -

Other attributes are passed to the element it renders.

DrawerDescription

Renders a <p> element.

ParameterTypeDefault
Render RenderFragment<PopupRenderProps>? -
ChildContent

The part's content.

RenderFragment? -

Other attributes are passed to the element it renders.

DrawerClose

Renders a <button> element.

ParameterTypeDefault
Disabled

Whether the component should ignore user interaction.

bool false
NativeButton bool? -
Render RenderFragment<PopupTriggerRenderProps>? -
ChildContent

The part's content.

RenderFragment? -

Other attributes are passed to the element it renders.

AttributeType
data-disabled

Present when the button is disabled.

-

DrawerViewport

Renders a <div> element.

ParameterTypeDefault
KeepMounted bool false
InitialFocus string? -
FinalFocus string? -
PositionerAttributes IReadOnlyDictionary<string, object>? -
Render RenderFragment<DialogPopupRenderProps>? -
ChildContent

The part's content.

RenderFragment? -

Other attributes are passed to the element it renders.

AttributeType
data-open

Present when the drawer is open.

-
data-closed

Present when the drawer is closed.

-
data-nested

Present when the drawer is nested within another drawer.

-
data-starting-style

Present when the drawer begins animating in.

-
data-ending-style

Present when the drawer is animating out.

-
CSS variableType
--drawer-keyboard-inset

The software keyboard inset, measured from the bottom edge of the layout viewport. Present only when the drawer is wrapped in DrawerVirtualKeyboardProvider.

CSS

DrawerHandle

DrawerIndent

Renders a <div> element.

ParameterTypeDefault
Render RenderFragment<PartRenderProps>? -
ChildContent

The part's content.

RenderFragment? -

Other attributes are passed to the element it renders.

DrawerIndentBackground

Renders a <div> element.

ParameterTypeDefault
Render RenderFragment<PartRenderProps>? -
ChildContent

The part's content.

RenderFragment? -

Other attributes are passed to the element it renders.

DrawerSwipeArea

Renders a <div> element.

ParameterTypeDefault
Disabled

Whether the component should ignore user interaction.

bool false
Render RenderFragment<PartRenderProps>? -
ChildContent

The part's content.

RenderFragment? -

Other attributes are passed to the element it renders.

AttributeType
data-open

Present when the drawer is open.

-
data-closed

Present when the drawer is closed.

-
data-disabled

Present when the swipe area is disabled.

-
data-swipe-direction

Indicates the swipe direction.

'up' | 'down' | 'left' | 'right'
data-swiping

Present when the drawer is being swiped.

-

DrawerVirtualKeyboardProvider

Doesn't render its own HTML element.

ParameterTypeDefault
ChildContent

The part's content.

RenderFragment? -