logo

Drawer

Examples

Simplest Usage. Drawer will be displayed on right, and it will be closed when you click the masked area.

expand code expand code

Use form in drawer with submit button.

expand code expand code

Use Drawer to quickly preview details of an object, such as those in a list.

expand code expand code

Render in current dom. custom container.

expand code expand code

Drawer event handling

For Drawer component:

  1. OnOpen: Execute before opening, and you can cancel the opening operation through the Cancel attribute of the parameter.
  2. OnClose: Before closing, you need to control the Visible paramter of the Drawer component through it.

For DrawerService:

  1. DrawerRef.OnOpen: Execute before opening, and call this method in Drawe.OnOpen event internally.
  2. DrawerRef.OnClosing: Execute before closing
  3. DrawerRef.OnClosed: Execute after shutdown
expand code expand code

The Drawer can appear from any edge of the screen.

expand code expand code

Set the offset in X or Y direction.

expand code expand code

Open a new drawer on top of an existing drawer to handle multi branch tasks.

expand code expand code

Usage of Drawer's service, examples demonstrate user-defined templates, custom components.

Template code: DrawerTemplateDemo.razor

@namespace AntDesign
@inherits FeedbackComponent<string, string>

<div>
    value: <Input @bind-Value="value" />
    <br/>
    <br/>
    <Button Type="primary" OnClick="OnClose">Confirm</Button>
</div>

@code{

    string value;

    protected override void OnInitialized()
    {
        value = base.Options;
        base.OnInitialized();
    }

    async void OnClose()
    {
        DrawerRef<string> drawerRef = base.FeedbackRef as DrawerRef<string>;
        await drawerRef!.CloseAsync(value);
    }
}
expand code expand code

use dropdown or popup in drawer.

expand code expand code

Drawer API#

Property Description Type Default Value
ChildContent ParameterThe content of Drawer. RenderFragment --
Content ParameterThe content of Drawer.

If AntDesign.Drawer.Content is a string, it will be rendered as HTML.

OneOf<RenderFragment, String> --
Closable ParameterWhether a close (x) button is visible on top right of the Drawer dialog or not. Boolean true
MaskClosable ParameterClicking on the mask (area outside the Drawer) to close the Drawer or not. Boolean true
Mask ParameterWhether to show mask or not. Boolean true
MaskStyle ParameterStyle for Drawer's mask element. String --
Keyboard ParameterWhether to support keyboard esc off Boolean true
Title ParameterThe title for Drawer. OneOf<RenderFragment, String> --
Placement ParameterThe placement of the Drawer, option could be left, top, right, bottom String right
BodyStyle ParameterBody style for modal body element. Such as height, padding etc. String --
HeaderStyle ParameterHeader style for modal header element. Such as height, padding etc. String --
WrapClassName ParameterThe class name of the container of the Drawer dialog. String --
Width ParameterWidth of the Drawer dialog, only when placement is 'left' or 'right'. String 256
Height ParameterHeight of the Drawer dialog, only when placement is 'top' or 'bottom'. String 256
ZIndex ParameterThe z-index of the Drawer. Int32 1000
OffsetX ParameterThe the X coordinate offset(px), only when placement is 'left' or 'right'. Int32 0
OffsetY ParameterThe the Y coordinate offset(px), only when placement is 'top' or 'bottom'. Int32 0
Visible ParameterWhether the Drawer dialog is visible or not. Boolean false
VisibleChanged ParameterEventCallback trigger on Visible was changed. EventCallback<Boolean> --
OnOpen ParameterSpecify a callback that will be called before drawer displayed EventCallback --
OnClose ParameterSpecify a callback that will be called when a user clicks mask, close button or Cancel button. EventCallback --
Handler Parameter RenderFragment --
Id ParameterID for the component's HTML String Uniquely Generated ID
Class ParameterSpecifies one or more class names for an DOM element. String --
Style ParameterSpecifies an inline style for a DOM element. String --
RefBack ParameterA ForwardRef instance. You can get a reference to the internal DOM by using AntDesign.ForwardRef.Current. ForwardRef --

DrawerService API#

Method Signature Return Type Description
CreateAsync(DrawerOptions options) Task<DrawerRef> Create and open a simple drawer without result
CreateAsync(DrawerOptions config, TComponentOptions options) Task<DrawerRef<TResult>> Create and open a drawer with the template
UpdateAsync(DrawerRef drawerRef) Task Update a drawer
CreateDialogAsync(DrawerOptions config, TComponentOptions options) Task<TResult> Create and open a drawer
CreateDialogAsync(TComponentOptions options, Boolean closable, Boolean maskClosable, String title, String width, Boolean mask, String placement) Task<TResult>

DrawerOptions API#

Property Description Type Default Value
Content The drawer body content. OneOf<RenderFragment, String> --
ChildContent RenderFragment --
Closable Whether a close (x) button is visible on top right of the Drawer dialog or not. Boolean true
MaskClosable Clicking on the mask (area outside the Drawer) to close the Drawer or not. Boolean true
Mask Whether to show mask or not. Boolean true
Keyboard Whether to support keyboard esc off Boolean true
Title The title for Drawer. OneOf<RenderFragment, String> --
Placement The placement of the Drawer - Possible values: "left", "right", "top", "bottom" String right
MaskStyle Style for Drawer's mask element. String --
BodyStyle Body style for Drawer body element. Such as height, padding etc. String --
HeaderStyle Header style for Drawer header element. Such as height, padding etc. String --
WrapClassName The class name of the container of the Drawer dialog. String --
Width Width of the Drawer dialog. String 256
Height Height of the Drawer dialog, only when placement is 'top' or 'bottom'. String 256
ZIndex The z-index of the Drawer. Int32 1000
OffsetX The the X coordinate offset(px), only when placement is 'left' or 'right'. Int32 0
OffsetY The the Y coordinate offset(px), only when placement is 'top' or 'bottom'. Int32 0
Visible If the drawer is visible or not Boolean false
Alert Message
文档已更新,请点击 此处 更新。
A new version of this app is available. Click here to update.