A draft in a bottom drawer
The draft stays in the host component while the modal opens and closes.
Keyboard
- Escape dismisses and returns focus.
- Tab remains in the open drawer.
States covered
- Closed
- Open
- Preserved draft
Install this complete example and its component dependencies.
npx shadcn@latest add https://ui.bld8.dev/r/example-basic-drawer.jsonComplete source
/*!
MIT License
Copyright (c) 2026 Jaison
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import {useState} from 'react';
import {Button,Drawer,DrawerClose,Field,Input,UIProvider} from '@bld8/ui';
import '@bld8/ui/styles.css';
export default function DrawerExample(){const [draft,setDraft]=useState('');return <UIProvider><Drawer title="Example project note" side="bottom" trigger={<Button variant="secondary">Open example note drawer</Button>}><Field label="Example note title"><Input value={draft} onChange={event=>setDraft(event.target.value)}/></Field><DrawerClose>Keep local example draft</DrawerClose></Drawer></UIProvider>;}