Sheet
A panel that slides in from the edge of the screen for secondary tasks, built on Bootstrap Offcanvas.
Installation
Usage
Use offcanvas-end (right), offcanvas-start (left), offcanvas-top or offcanvas-bottom to choose the side. The trigger needs data-bs-toggle="offcanvas" and data-bs-target. Width: --bs-offcanvas-width on .bootcn-sheet.
Accessibility
- Bootstrap gives it
role="dialog"andaria-modalwhile open, traps focus inside, closes it on Escape and returns focus to the trigger. - The title names the dialog (
aria-labelledby).
Dependencies
- Bootstrap 5.3+ CSS and the JS bundle.
themes/tokens/tokens.css.- The
buttoncomponent. - The
inputcomponent.
Source
The exact files the CLI installs (sheet@1.0.0). View on GitHub · Report an issue
html
<button
class="btn bootcn-button bootcn-button--outline"
type="button"
data-bs-toggle="offcanvas"
data-bs-target="#bootcn-sheet"
aria-controls="bootcn-sheet"
>
Edit profile
</button>
<div
class="offcanvas offcanvas-end bootcn-sheet"
tabindex="-1"
id="bootcn-sheet"
aria-labelledby="bootcn-sheet-title"
>
<div class="offcanvas-header bootcn-sheet__header">
<div>
<h2 class="offcanvas-title bootcn-sheet__title" id="bootcn-sheet-title">Edit profile</h2>
<p class="bootcn-sheet__description">Change your public details. Save when you are done.</p>
</div>
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body bootcn-sheet__body">
<div class="bootcn-field">
<label class="form-label bootcn-field__label" for="bootcn-sheet-name">Name</label>
<input
class="form-control bootcn-input"
type="text"
id="bootcn-sheet-name"
name="name"
value="Maria Papadopoulou"
autocomplete="name"
/>
</div>
<div class="bootcn-field">
<label class="form-label bootcn-field__label" for="bootcn-sheet-username">Username</label>
<input
class="form-control bootcn-input"
type="text"
id="bootcn-sheet-username"
name="username"
value="@maria"
autocomplete="username"
/>
</div>
</div>
<div class="bootcn-sheet__footer">
<button type="button" class="btn bootcn-button bootcn-button--default">Save changes</button>
<button
type="button"
class="btn bootcn-button bootcn-button--outline"
data-bs-dismiss="offcanvas"
>
Cancel
</button>
</div>
</div>css
.bootcn-sheet {
--bs-offcanvas-width: min(24rem, 100vw);
--bs-offcanvas-height: auto;
--bs-offcanvas-bg: var(--bootcn-background);
--bs-offcanvas-color: var(--bootcn-foreground);
--bs-offcanvas-border-color: var(--bootcn-border-color);
--bs-offcanvas-box-shadow: var(--bootcn-shadow-lg);
--bs-offcanvas-padding-x: 1.5rem;
--bs-offcanvas-padding-y: 1.5rem;
box-shadow: var(--bs-offcanvas-box-shadow);
}
.bootcn-sheet__header {
align-items: flex-start;
gap: 1rem;
padding-bottom: 0.5rem;
}
.bootcn-sheet__title {
margin: 0;
font-size: 1.125rem;
font-weight: 600;
}
.bootcn-sheet__description {
margin: 0.375rem 0 0;
color: var(--bootcn-muted-foreground);
font-size: 0.875rem;
}
.bootcn-sheet__body {
display: flex;
flex-direction: column;
gap: 1rem;
}
.bootcn-sheet__footer {
display: flex;
flex-direction: column;
gap: 0.5rem;
padding: 1rem var(--bs-offcanvas-padding-x) var(--bs-offcanvas-padding-y);
}
