Mobilens English

控件 · 浮层

底部弹层

所有状态

何时出现
行为规则

    用法

    import { useState } from 'react';
    import { BottomSheet } from '@/components/mobilens/BottomSheet';
    import { Button } from '@/components/mobilens/Button';
    
    export function ShareButton({ copyLink, invite }: { copyLink: () => void; invite: () => void }) {
      const [open, setOpen] = useState(false);
      const run = (action: () => void) => () => {
        setOpen(false);
        action();
      };
    
      return (
        <>
          <Button title="Share" variant="secondary" onPress={() => setOpen(true)} />
          {/* Render it as the screen's last child. */}
          <BottomSheet visible={open} onClose={() => setOpen(false)} title="Share this list">
            <Button title="Copy link" variant="secondary" onPress={run(copyLink)} />
            <Button title="Invite people" onPress={run(invite)} />
          </BottomSheet>
        </>
      );
    }
    

    API

    参数类型默认值说明
    visible boolean – Open or closed. Closing animates out before the sheet is removed.
    onClose () => void – Called when the user asks to close it: backdrop, drag down or back button. Set visible to false.
    title? string – Shown at the top and announced when the sheet opens.
    children ReactNode – The sheet's content.
    dismissible? boolean true false keeps it open on backdrop taps, drags and back, for example while it saves.

    用在这些流程里