Full-height side panel built on the native dialog element, sliding in from the right or left.
<x-markas.drawer title="Filter products">
<x-slot:trigger>
<x-markas.button variant="secondary">Open filters</x-markas.button>
</x-slot:trigger>
Choose a category and price range to filter the product list.
<x-slot:footer>
<x-markas.button variant="secondary" type="submit" value="cancel">Cancel</x-markas.button>
<x-markas.button type="submit" value="apply">Apply</x-markas.button>
</x-slot:footer>
</x-markas.drawer>import { Button } from "@/components/markas/Button";
import { Drawer } from "@/components/markas/Drawer";
export default function DrawerExample() {
return (
<Drawer
title="Filter products"
trigger={<Button variant="secondary">Open filters</Button>}
footer={
<>
<Button variant="secondary" type="submit" value="cancel">
Cancel
</Button>
<Button type="submit" value="apply">
Apply
</Button>
</>
}
>
Choose a category and price range to filter the product list.
</Drawer>
);
}<script setup lang="ts">
import Button from "@/components/markas/Button.vue";
import Drawer from "@/components/markas/Drawer.vue";
</script>
<template>
<Drawer title="Filter products">
<template #trigger>
<Button variant="secondary">Open filters</Button>
</template>
Choose a category and price range to filter the product list.
<template #footer>
<Button variant="secondary" type="submit" value="cancel">Cancel</Button>
<Button type="submit" value="apply">Apply</Button>
</template>
</Drawer>
</template><script lang="ts">
import Button from "$lib/components/markas/Button.svelte";
import Drawer from "$lib/components/markas/Drawer.svelte";
</script>
<Drawer title="Filter products">
{#snippet trigger()}
<Button variant="secondary">Open filters</Button>
{/snippet}
Choose a category and price range to filter the product list.
{#snippet footer()}
<Button variant="secondary" type="submit" value="cancel">Cancel</Button>
<Button type="submit" value="apply">Apply</Button>
{/snippet}
</Drawer>---
import Button from "@/components/markas/Button.astro";
import Drawer from "@/components/markas/Drawer.astro";
---
<Drawer title="Filter products">
<Button slot="trigger" variant="secondary">Open filters</Button>
Choose a category and price range to filter the product list.
<Fragment slot="footer">
<Button variant="secondary" type="submit" value="cancel">Cancel</Button>
<Button type="submit" value="apply">Apply</Button>
</Fragment>
</Drawer>import { Component } from "@angular/core";
import { Button } from "./markas/button.component";
import { Drawer } from "./markas/drawer.component";
@Component({
selector: "markas-example",
imports: [Button, Drawer],
template: `
<markas-drawer title="Filter products">
<button markas-button trigger variant="secondary">Open filters</button>
Choose a category and price range to filter the product list.
<ng-container footer>
<button markas-button variant="secondary" type="submit" value="cancel">
Cancel
</button>
<button markas-button type="submit" value="apply">Apply</button>
</ng-container>
</markas-drawer>
`,
})
export default class DrawerExample {}Examples
Left side navigation
@php
$link = 'block rounded-md px-3 py-2 font-medium text-ink transition-colors duration-150 ease-out hover:bg-subtle motion-reduce:transition-none';
@endphp
<div class="flex justify-center">
<x-markas.drawer side="left" title="Menu">
<x-slot:trigger>
<x-markas.button variant="secondary" aria-label="Open menu" class="size-10 px-0">
<svg class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 6h16M4 12h16M4 18h16" /></svg>
</x-markas.button>
</x-slot:trigger>
<nav aria-label="Main">
<ul class="grid gap-1">
<li><a class="{{ $link }}" href="#dashboard">Dashboard</a></li>
<li><a class="{{ $link }}" href="#projects">Projects</a></li>
<li><a class="{{ $link }}" href="#team">Team</a></li>
<li><a class="{{ $link }}" href="#settings">Settings</a></li>
</ul>
</nav>
</x-markas.drawer>
</div>import { Button } from "@/components/markas/Button";
import { Drawer } from "@/components/markas/Drawer";
const link =
"block rounded-md px-3 py-2 font-medium text-ink transition-colors duration-150 ease-out hover:bg-subtle motion-reduce:transition-none";
export default function Example() {
return (
<div className="flex justify-center">
<Drawer
side="left"
title="Menu"
trigger={
<Button
variant="secondary"
aria-label="Open menu"
className="size-10 px-0"
>
<svg
className="size-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
aria-hidden="true"
>
<path d="M4 6h16M4 12h16M4 18h16" />
</svg>
</Button>
}
>
<nav aria-label="Main">
<ul className="grid gap-1">
<li>
<a className={link} href="#dashboard">
Dashboard
</a>
</li>
<li>
<a className={link} href="#projects">
Projects
</a>
</li>
<li>
<a className={link} href="#team">
Team
</a>
</li>
<li>
<a className={link} href="#settings">
Settings
</a>
</li>
</ul>
</nav>
</Drawer>
</div>
);
}<script setup lang="ts">
import Button from "@/components/markas/Button.vue";
import Drawer from "@/components/markas/Drawer.vue";
const link =
"block rounded-md px-3 py-2 font-medium text-ink transition-colors duration-150 ease-out hover:bg-subtle motion-reduce:transition-none";
</script>
<template>
<div class="flex justify-center">
<Drawer side="left" title="Menu">
<template #trigger>
<Button variant="secondary" aria-label="Open menu" class="size-10 px-0">
<svg
class="size-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<path d="M4 6h16M4 12h16M4 18h16" />
</svg>
</Button>
</template>
<nav aria-label="Main">
<ul class="grid gap-1">
<li><a :class="link" href="#dashboard">Dashboard</a></li>
<li><a :class="link" href="#projects">Projects</a></li>
<li><a :class="link" href="#team">Team</a></li>
<li><a :class="link" href="#settings">Settings</a></li>
</ul>
</nav>
</Drawer>
</div>
</template><script lang="ts">
import Button from "$lib/components/markas/Button.svelte";
import Drawer from "$lib/components/markas/Drawer.svelte";
const link =
"block rounded-md px-3 py-2 font-medium text-ink transition-colors duration-150 ease-out hover:bg-subtle motion-reduce:transition-none";
</script>
<div class="flex justify-center">
<Drawer side="left" title="Menu">
{#snippet trigger()}
<Button variant="secondary" aria-label="Open menu" class="size-10 px-0">
<svg
class="size-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<path d="M4 6h16M4 12h16M4 18h16" />
</svg>
</Button>
{/snippet}
<nav aria-label="Main">
<ul class="grid gap-1">
<li><a class={link} href="#dashboard">Dashboard</a></li>
<li><a class={link} href="#projects">Projects</a></li>
<li><a class={link} href="#team">Team</a></li>
<li><a class={link} href="#settings">Settings</a></li>
</ul>
</nav>
</Drawer>
</div>---
import Button from "@/components/markas/Button.astro";
import Drawer from "@/components/markas/Drawer.astro";
const link =
"block rounded-md px-3 py-2 font-medium text-ink transition-colors duration-150 ease-out hover:bg-subtle motion-reduce:transition-none";
---
<div class="flex justify-center">
<Drawer side="left" title="Menu">
<Button
slot="trigger"
variant="secondary"
aria-label="Open menu"
class="size-10 px-0"
>
<svg
class="size-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<path d="M4 6h16M4 12h16M4 18h16"></path>
</svg>
</Button>
<nav aria-label="Main">
<ul class="grid gap-1">
<li><a class={link} href="#dashboard">Dashboard</a></li>
<li><a class={link} href="#projects">Projects</a></li>
<li><a class={link} href="#team">Team</a></li>
<li><a class={link} href="#settings">Settings</a></li>
</ul>
</nav>
</Drawer>
</div>import { Component } from "@angular/core";
import { Button } from "./markas/button.component";
import { Drawer } from "./markas/drawer.component";
@Component({
selector: "markas-example",
imports: [Button, Drawer],
template: `
<div class="flex justify-center">
<markas-drawer side="left" title="Menu">
<button
markas-button
trigger
variant="secondary"
aria-label="Open menu"
class="size-10 px-0"
>
<svg
class="size-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<path d="M4 6h16M4 12h16M4 18h16" />
</svg>
</button>
<nav aria-label="Main">
<ul class="grid gap-1">
<li><a [class]="link" href="#dashboard">Dashboard</a></li>
<li><a [class]="link" href="#projects">Projects</a></li>
<li><a [class]="link" href="#team">Team</a></li>
<li><a [class]="link" href="#settings">Settings</a></li>
</ul>
</nav>
</markas-drawer>
</div>
`,
})
export default class DrawerLeftExample {
protected readonly link =
"block rounded-md px-3 py-2 font-medium text-ink transition-colors duration-150 ease-out hover:bg-subtle motion-reduce:transition-none";
}Detail panel
<div class="flex justify-center">
<x-markas.drawer title="Order #1042">
<x-slot:trigger>
<x-markas.button variant="secondary">View order</x-markas.button>
</x-slot:trigger>
<dl class="grid grid-cols-2 gap-y-3">
<dt>Customer</dt>
<dd class="text-ink">Rina Hartono</dd>
<dt>Placed on</dt>
<dd class="text-ink">12 Oct 2026</dd>
<dt>Items</dt>
<dd class="text-ink">3</dd>
<dt>Total</dt>
<dd class="font-medium text-ink">$128.00</dd>
</dl>
<x-slot:footer>
<x-markas.button variant="secondary" type="submit" value="close">Close</x-markas.button>
<x-markas.button type="submit" value="ship">Mark as shipped</x-markas.button>
</x-slot:footer>
</x-markas.drawer>
</div>import { Button } from "@/components/markas/Button";
import { Drawer } from "@/components/markas/Drawer";
export default function Example() {
return (
<div className="flex justify-center">
<Drawer
title="Order #1042"
trigger={<Button variant="secondary">View order</Button>}
footer={
<>
<Button variant="secondary" type="submit" value="close">
Close
</Button>
<Button type="submit" value="ship">
Mark as shipped
</Button>
</>
}
>
<dl className="grid grid-cols-2 gap-y-3">
<dt>Customer</dt>
<dd className="text-ink">Rina Hartono</dd>
<dt>Placed on</dt>
<dd className="text-ink">12 Oct 2026</dd>
<dt>Items</dt>
<dd className="text-ink">3</dd>
<dt>Total</dt>
<dd className="font-medium text-ink">$128.00</dd>
</dl>
</Drawer>
</div>
);
}<script setup lang="ts">
import Button from "@/components/markas/Button.vue";
import Drawer from "@/components/markas/Drawer.vue";
</script>
<template>
<div class="flex justify-center">
<Drawer title="Order #1042">
<template #trigger>
<Button variant="secondary">View order</Button>
</template>
<dl class="grid grid-cols-2 gap-y-3">
<dt>Customer</dt>
<dd class="text-ink">Rina Hartono</dd>
<dt>Placed on</dt>
<dd class="text-ink">12 Oct 2026</dd>
<dt>Items</dt>
<dd class="text-ink">3</dd>
<dt>Total</dt>
<dd class="font-medium text-ink">$128.00</dd>
</dl>
<template #footer>
<Button variant="secondary" type="submit" value="close">Close</Button>
<Button type="submit" value="ship">Mark as shipped</Button>
</template>
</Drawer>
</div>
</template><script lang="ts">
import Button from "$lib/components/markas/Button.svelte";
import Drawer from "$lib/components/markas/Drawer.svelte";
</script>
<div class="flex justify-center">
<Drawer title="Order #1042">
{#snippet trigger()}
<Button variant="secondary">View order</Button>
{/snippet}
<dl class="grid grid-cols-2 gap-y-3">
<dt>Customer</dt>
<dd class="text-ink">Rina Hartono</dd>
<dt>Placed on</dt>
<dd class="text-ink">12 Oct 2026</dd>
<dt>Items</dt>
<dd class="text-ink">3</dd>
<dt>Total</dt>
<dd class="font-medium text-ink">$128.00</dd>
</dl>
{#snippet footer()}
<Button variant="secondary" type="submit" value="close">Close</Button>
<Button type="submit" value="ship">Mark as shipped</Button>
{/snippet}
</Drawer>
</div>---
import Button from "@/components/markas/Button.astro";
import Drawer from "@/components/markas/Drawer.astro";
---
<div class="flex justify-center">
<Drawer title="Order #1042">
<Button slot="trigger" variant="secondary">View order</Button>
<dl class="grid grid-cols-2 gap-y-3">
<dt>Customer</dt>
<dd class="text-ink">Rina Hartono</dd>
<dt>Placed on</dt>
<dd class="text-ink">12 Oct 2026</dd>
<dt>Items</dt>
<dd class="text-ink">3</dd>
<dt>Total</dt>
<dd class="font-medium text-ink">$128.00</dd>
</dl>
<Fragment slot="footer">
<Button variant="secondary" type="submit" value="close">Close</Button>
<Button type="submit" value="ship">Mark as shipped</Button>
</Fragment>
</Drawer>
</div>import { Component } from "@angular/core";
import { Button } from "./markas/button.component";
import { Drawer } from "./markas/drawer.component";
@Component({
selector: "markas-example",
imports: [Button, Drawer],
template: `
<div class="flex justify-center">
<markas-drawer title="Order #1042">
<button markas-button trigger variant="secondary">View order</button>
<dl class="grid grid-cols-2 gap-y-3">
<dt>Customer</dt>
<dd class="text-ink">Rina Hartono</dd>
<dt>Placed on</dt>
<dd class="text-ink">12 Oct 2026</dd>
<dt>Items</dt>
<dd class="text-ink">3</dd>
<dt>Total</dt>
<dd class="font-medium text-ink">$128.00</dd>
</dl>
<ng-container footer>
<button markas-button variant="secondary" type="submit" value="close">
Close
</button>
<button markas-button type="submit" value="ship">
Mark as shipped
</button>
</ng-container>
</markas-drawer>
</div>
`,
})
export default class DrawerDetailsExample {}Filters
<div class="flex justify-center">
<x-markas.drawer title="Filter products">
<x-slot:trigger>
<x-markas.button variant="secondary">
<svg class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 5h18M6 12h12M10 19h4" /></svg>
Filters
</x-markas.button>
</x-slot:trigger>
<fieldset class="grid gap-3">
<legend class="mb-3 font-medium text-ink">Category</legend>
<x-markas.checkbox name="category-shoes" label="Shoes" />
<x-markas.checkbox name="category-bags" label="Bags" />
<x-markas.checkbox name="category-accessories" label="Accessories" />
</fieldset>
<x-slot:footer>
<x-markas.button variant="secondary" type="submit" value="reset">Reset</x-markas.button>
<x-markas.button type="submit" value="apply">Show results</x-markas.button>
</x-slot:footer>
</x-markas.drawer>
</div>import { Button } from "@/components/markas/Button";
import { Checkbox } from "@/components/markas/Checkbox";
import { Drawer } from "@/components/markas/Drawer";
export default function Example() {
return (
<div className="flex justify-center">
<Drawer
title="Filter products"
trigger={
<Button variant="secondary">
<svg
className="size-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
aria-hidden="true"
>
<path d="M3 5h18M6 12h12M10 19h4" />
</svg>
Filters
</Button>
}
footer={
<>
<Button variant="secondary" type="submit" value="reset">
Reset
</Button>
<Button type="submit" value="apply">
Show results
</Button>
</>
}
>
<fieldset className="grid gap-3">
<legend className="mb-3 font-medium text-ink">Category</legend>
<Checkbox name="category-shoes" label="Shoes" />
<Checkbox name="category-bags" label="Bags" />
<Checkbox name="category-accessories" label="Accessories" />
</fieldset>
</Drawer>
</div>
);
}<script setup lang="ts">
import Button from "@/components/markas/Button.vue";
import Checkbox from "@/components/markas/Checkbox.vue";
import Drawer from "@/components/markas/Drawer.vue";
</script>
<template>
<div class="flex justify-center">
<Drawer title="Filter products">
<template #trigger>
<Button variant="secondary">
<svg
class="size-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<path d="M3 5h18M6 12h12M10 19h4" />
</svg>
Filters
</Button>
</template>
<fieldset class="grid gap-3">
<legend class="mb-3 font-medium text-ink">Category</legend>
<Checkbox name="category-shoes" label="Shoes" />
<Checkbox name="category-bags" label="Bags" />
<Checkbox name="category-accessories" label="Accessories" />
</fieldset>
<template #footer>
<Button variant="secondary" type="submit" value="reset">Reset</Button>
<Button type="submit" value="apply">Show results</Button>
</template>
</Drawer>
</div>
</template><script lang="ts">
import Button from "$lib/components/markas/Button.svelte";
import Checkbox from "$lib/components/markas/Checkbox.svelte";
import Drawer from "$lib/components/markas/Drawer.svelte";
</script>
<div class="flex justify-center">
<Drawer title="Filter products">
{#snippet trigger()}
<Button variant="secondary">
<svg
class="size-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<path d="M3 5h18M6 12h12M10 19h4" />
</svg>
Filters
</Button>
{/snippet}
<fieldset class="grid gap-3">
<legend class="mb-3 font-medium text-ink">Category</legend>
<Checkbox name="category-shoes" label="Shoes" />
<Checkbox name="category-bags" label="Bags" />
<Checkbox name="category-accessories" label="Accessories" />
</fieldset>
{#snippet footer()}
<Button variant="secondary" type="submit" value="reset">Reset</Button>
<Button type="submit" value="apply">Show results</Button>
{/snippet}
</Drawer>
</div>---
import Button from "@/components/markas/Button.astro";
import Checkbox from "@/components/markas/Checkbox.astro";
import Drawer from "@/components/markas/Drawer.astro";
---
<div class="flex justify-center">
<Drawer title="Filter products">
<Button slot="trigger" variant="secondary">
<svg
class="size-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<path d="M3 5h18M6 12h12M10 19h4"></path>
</svg>
Filters
</Button>
<fieldset class="grid gap-3">
<legend class="mb-3 font-medium text-ink">Category</legend>
<Checkbox name="category-shoes" label="Shoes" />
<Checkbox name="category-bags" label="Bags" />
<Checkbox name="category-accessories" label="Accessories" />
</fieldset>
<Fragment slot="footer">
<Button variant="secondary" type="submit" value="reset">Reset</Button>
<Button type="submit" value="apply">Show results</Button>
</Fragment>
</Drawer>
</div>import { Component } from "@angular/core";
import { Button } from "./markas/button.component";
import { Checkbox } from "./markas/checkbox.component";
import { Drawer } from "./markas/drawer.component";
@Component({
selector: "markas-example",
imports: [Button, Checkbox, Drawer],
template: `
<div class="flex justify-center">
<markas-drawer title="Filter products">
<button markas-button trigger variant="secondary">
<svg
class="size-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<path d="M3 5h18M6 12h12M10 19h4" />
</svg>
Filters
</button>
<fieldset class="grid gap-3">
<legend class="mb-3 font-medium text-ink">Category</legend>
<markas-checkbox name="category-shoes" label="Shoes" />
<markas-checkbox name="category-bags" label="Bags" />
<markas-checkbox name="category-accessories" label="Accessories" />
</fieldset>
<ng-container footer>
<button markas-button variant="secondary" type="submit" value="reset">
Reset
</button>
<button markas-button type="submit" value="apply">
Show results
</button>
</ng-container>
</markas-drawer>
</div>
`,
})
export default class DrawerFiltersExample {}With form
<div class="flex justify-center">
<x-markas.drawer title="Edit profile">
<x-slot:trigger>
<x-markas.button>Edit profile</x-markas.button>
</x-slot:trigger>
<div class="grid gap-4">
<x-markas.input name="profile-name" label="Display name" placeholder="Budi Santoso" />
<x-markas.input name="profile-role" label="Job title" placeholder="Product designer" />
<x-markas.input name="profile-website" type="url" label="Website" placeholder="https://example.com" />
</div>
<x-slot:footer>
<x-markas.button variant="secondary" type="submit" value="cancel">Cancel</x-markas.button>
<x-markas.button type="submit" value="save">Save changes</x-markas.button>
</x-slot:footer>
</x-markas.drawer>
</div>import { Button } from "@/components/markas/Button";
import { Drawer } from "@/components/markas/Drawer";
import { Input } from "@/components/markas/Input";
export default function Example() {
return (
<div className="flex justify-center">
<Drawer
title="Edit profile"
trigger={<Button>Edit profile</Button>}
footer={
<>
<Button variant="secondary" type="submit" value="cancel">
Cancel
</Button>
<Button type="submit" value="save">
Save changes
</Button>
</>
}
>
<div className="grid gap-4">
<Input
name="profile-name"
label="Display name"
placeholder="Budi Santoso"
/>
<Input
name="profile-role"
label="Job title"
placeholder="Product designer"
/>
<Input
name="profile-website"
type="url"
label="Website"
placeholder="https://example.com"
/>
</div>
</Drawer>
</div>
);
}<script setup lang="ts">
import Button from "@/components/markas/Button.vue";
import Drawer from "@/components/markas/Drawer.vue";
import Input from "@/components/markas/Input.vue";
</script>
<template>
<div class="flex justify-center">
<Drawer title="Edit profile">
<template #trigger>
<Button>Edit profile</Button>
</template>
<div class="grid gap-4">
<Input
name="profile-name"
label="Display name"
placeholder="Budi Santoso"
/>
<Input
name="profile-role"
label="Job title"
placeholder="Product designer"
/>
<Input
name="profile-website"
type="url"
label="Website"
placeholder="https://example.com"
/>
</div>
<template #footer>
<Button variant="secondary" type="submit" value="cancel">Cancel</Button>
<Button type="submit" value="save">Save changes</Button>
</template>
</Drawer>
</div>
</template><script lang="ts">
import Button from "$lib/components/markas/Button.svelte";
import Drawer from "$lib/components/markas/Drawer.svelte";
import Input from "$lib/components/markas/Input.svelte";
</script>
<div class="flex justify-center">
<Drawer title="Edit profile">
{#snippet trigger()}
<Button>Edit profile</Button>
{/snippet}
<div class="grid gap-4">
<Input
name="profile-name"
label="Display name"
placeholder="Budi Santoso"
/>
<Input
name="profile-role"
label="Job title"
placeholder="Product designer"
/>
<Input
name="profile-website"
type="url"
label="Website"
placeholder="https://example.com"
/>
</div>
{#snippet footer()}
<Button variant="secondary" type="submit" value="cancel">Cancel</Button>
<Button type="submit" value="save">Save changes</Button>
{/snippet}
</Drawer>
</div>---
import Button from "@/components/markas/Button.astro";
import Drawer from "@/components/markas/Drawer.astro";
import Input from "@/components/markas/Input.astro";
---
<div class="flex justify-center">
<Drawer title="Edit profile">
<Button slot="trigger">Edit profile</Button>
<div class="grid gap-4">
<Input name="profile-name" label="Display name" placeholder="Budi Santoso" />
<Input name="profile-role" label="Job title" placeholder="Product designer" />
<Input
name="profile-website"
type="url"
label="Website"
placeholder="https://example.com"
/>
</div>
<Fragment slot="footer">
<Button variant="secondary" type="submit" value="cancel">Cancel</Button>
<Button type="submit" value="save">Save changes</Button>
</Fragment>
</Drawer>
</div>import { Component } from "@angular/core";
import { Button } from "./markas/button.component";
import { Drawer } from "./markas/drawer.component";
import { Input } from "./markas/input.component";
@Component({
selector: "markas-example",
imports: [Button, Drawer, Input],
template: `
<div class="flex justify-center">
<markas-drawer title="Edit profile">
<button markas-button trigger>Edit profile</button>
<div class="grid gap-4">
<markas-input
name="profile-name"
label="Display name"
placeholder="Budi Santoso"
/>
<markas-input
name="profile-role"
label="Job title"
placeholder="Product designer"
/>
<markas-input
name="profile-website"
type="url"
label="Website"
placeholder="https://example.com"
/>
</div>
<ng-container footer>
<button
markas-button
variant="secondary"
type="submit"
value="cancel"
>
Cancel
</button>
<button markas-button type="submit" value="save">Save changes</button>
</ng-container>
</markas-drawer>
</div>
`,
})
export default class DrawerFormExample {}Installation
npx markasui@latest add drawerpnpm dlx markasui@latest add draweryarn dlx markasui@latest add drawerbunx --bun markasui@latest add drawer- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Install the dependency:
npm install alpinejs - Copy the component source below to
resources/views/components/markas/drawer.blade.php.
resources/views/components/markas/drawer.blade.php
@props([
'title',
'side' => 'right',
'closeLabel' => 'Close',
])
@php
$dialog = 'fixed inset-y-0 m-0 h-dvh max-h-dvh w-full max-w-sm border-line bg-surface p-0 text-ink shadow-overlay transition-transform duration-200 ease-out backdrop:bg-ink/40 motion-reduce:transition-none';
$sides = [
'right' => 'right-0 left-auto border-l starting:open:translate-x-full',
'left' => 'right-auto left-0 border-r starting:open:-translate-x-full',
];
$panel = 'flex h-full flex-col gap-4 p-6';
$header = 'flex items-start justify-between gap-4';
$titleClass = 'text-lg font-semibold text-ink';
$body = 'flex-1 overflow-y-auto text-sm text-muted';
$footerClass = 'flex flex-wrap justify-end gap-2';
$close = 'inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted transition-colors duration-150 ease-out hover:bg-subtle hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none';
// Same id on every render, so Livewire's morph (which matches elements by id) keeps the element. Pass `id` to set it.
$idKey = 'markas-drawer|'.(isset($this) && $this instanceof \Livewire\Component ? $this->getId() : '').'|'.($attributes->get('wire:key') ?? $attributes->whereStartsWith('wire:model')->first() ?? $attributes->get('name')).'|';
for ($idIndex = 0; $__env->hasRenderedOnce($idKey.$idIndex); $idIndex++);
$__env->markAsRenderedOnce($idKey.$idIndex);
$id = $attributes->get('id') ?? 'markas-drawer-'.hash('xxh32', $idKey.$idIndex);
@endphp
{{-- wire:model and x-model bind the open state (x-modelable), so a boolean property can open and close the dialog. --}}
<div
class="contents"
x-data="{
open: false,
init() {
this.$watch('open', (value) => {
const dialog = this.$refs.dialog;
if (value && ! dialog.open) dialog.showModal();
if (! value && dialog.open) dialog.close();
});
},
}"
x-modelable="open"
{{ $attributes->whereStartsWith(['wire:model', 'x-model']) }}
>
@isset($trigger)
<div class="contents" @click="$refs.dialog.showModal(); open = true">{{ $trigger }}</div>
@endisset
<dialog
wire:ignore.self
x-ref="dialog"
:data-state="open ? 'open' : 'closed'"
@close="open = false"
@click.self="$refs.dialog.close()"
{{ $attributes->whereDoesntStartWith(['wire:model', 'x-model'])->merge(['id' => $id, 'aria-labelledby' => $id.'-title', 'data-state' => 'closed'])->class([$dialog, $sides[$side]]) }}
>
<div class="{{ $panel }}">
<div class="{{ $header }}">
<h2 id="{{ $id }}-title" class="{{ $titleClass }}">{{ $title }}</h2>
<form method="dialog">
<button type="submit" class="{{ $close }}" aria-label="{{ $closeLabel }}">
<svg class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18M6 6l12 12" /></svg>
</button>
</form>
</div>
<div class="{{ $body }}">{{ $slot }}</div>
@isset($footer)
<form method="dialog" class="{{ $footerClass }}">{{ $footer }}</form>
@endisset
</div>
</dialog>
</div>- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/Drawer.tsx.
src/components/markas/Drawer.tsx
"use client";
import {
useId,
useRef,
useState,
type ComponentProps,
type MouseEvent,
type ReactNode,
} from "react";
const dialogClass =
"fixed inset-y-0 m-0 h-dvh max-h-dvh w-full max-w-sm border-line bg-surface p-0 text-ink shadow-overlay transition-transform duration-200 ease-out backdrop:bg-ink/40 motion-reduce:transition-none";
const sides = {
right: "right-0 left-auto border-l starting:open:translate-x-full",
left: "right-auto left-0 border-r starting:open:-translate-x-full",
};
const panel = "flex h-full flex-col gap-4 p-6";
const header = "flex items-start justify-between gap-4";
const titleClass = "text-lg font-semibold text-ink";
const body = "flex-1 overflow-y-auto text-sm text-muted";
const footerClass = "flex flex-wrap justify-end gap-2";
const close =
"inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted transition-colors duration-150 ease-out hover:bg-subtle hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none";
const cx = (...c: (string | false | null | undefined)[]) =>
c.filter(Boolean).join(" ");
export type DrawerProps = Omit<
ComponentProps<"dialog">,
"title" | "ref" | "open"
> & {
title: ReactNode;
side?: keyof typeof sides;
trigger?: ReactNode;
footer?: ReactNode;
/** Label aksesibel tombol tutup. */
closeLabel?: string;
};
export function Drawer({
title,
side = "right",
closeLabel = "Close",
trigger,
footer,
id,
className,
children,
onClose,
onClick,
...props
}: DrawerProps) {
const generatedId = useId();
const dialogId = id ?? generatedId;
const dialogRef = useRef<HTMLDialogElement>(null);
const [open, setOpen] = useState(false);
const show = () => {
dialogRef.current?.showModal();
setOpen(true);
};
const handleClick = (event: MouseEvent<HTMLDialogElement>) => {
if (event.target === event.currentTarget) dialogRef.current?.close();
onClick?.(event);
};
return (
<div className="contents">
{trigger && (
<div className="contents" onClick={show}>
{trigger}
</div>
)}
<dialog
ref={dialogRef}
id={dialogId}
aria-labelledby={`${dialogId}-title`}
data-state={open ? "open" : "closed"}
className={cx(dialogClass, sides[side], className)}
onClose={(event) => {
setOpen(false);
onClose?.(event);
}}
onClick={handleClick}
{...props}
>
<div className={panel}>
<div className={header}>
<h2 id={`${dialogId}-title`} className={titleClass}>
{title}
</h2>
<form method="dialog">
<button type="submit" className={close} aria-label={closeLabel}>
<svg
className="size-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
aria-hidden="true"
>
<path d="M18 6 6 18M6 6l12 12" />
</svg>
</button>
</form>
</div>
<div className={body}>{children}</div>
{footer && (
<form method="dialog" className={footerClass}>
{footer}
</form>
)}
</div>
</dialog>
</div>
);
}- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/Drawer.vue.
src/components/markas/Drawer.vue
<script setup lang="ts">
import { computed, ref, useId, useTemplateRef } from "vue";
defineOptions({ inheritAttrs: false });
const sides = {
right: "right-0 left-auto border-l starting:open:translate-x-full",
left: "right-auto left-0 border-r starting:open:-translate-x-full",
};
const props = withDefaults(
defineProps<{
title: string;
side?: keyof typeof sides;
id?: string;
closeLabel?: string;
}>(),
{ side: "right", id: undefined, closeLabel: "Close" },
);
const dialogClass =
"fixed inset-y-0 m-0 h-dvh max-h-dvh w-full max-w-sm border-line bg-surface p-0 text-ink shadow-overlay transition-transform duration-200 ease-out backdrop:bg-ink/40 motion-reduce:transition-none";
const panel = "flex h-full flex-col gap-4 p-6";
const header = "flex items-start justify-between gap-4";
const titleClass = "text-lg font-semibold text-ink";
const body = "flex-1 overflow-y-auto text-sm text-muted";
const footerClass = "flex flex-wrap justify-end gap-2";
const close =
"inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted transition-colors duration-150 ease-out hover:bg-subtle hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none";
const generatedId = useId();
const dialogId = computed(() => props.id ?? generatedId);
const dialog = useTemplateRef<HTMLDialogElement>("dialog");
const open = ref(false);
function show() {
dialog.value?.showModal();
open.value = true;
}
</script>
<template>
<div class="contents">
<div v-if="$slots.trigger" class="contents" @click="show">
<slot name="trigger" />
</div>
<dialog
:id="dialogId"
ref="dialog"
:aria-labelledby="`${dialogId}-title`"
:data-state="open ? 'open' : 'closed'"
:class="[dialogClass, sides[props.side]]"
v-bind="$attrs"
@close="open = false"
@click.self="dialog?.close()"
>
<div :class="panel">
<div :class="header">
<h2 :id="`${dialogId}-title`" :class="titleClass">
{{ props.title }}
</h2>
<form method="dialog">
<button type="submit" :class="close" :aria-label="props.closeLabel">
<svg
class="size-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<path d="M18 6 6 18M6 6l12 12" />
</svg>
</button>
</form>
</div>
<div :class="body"><slot /></div>
<form v-if="$slots.footer" method="dialog" :class="footerClass">
<slot name="footer" />
</form>
</div>
</dialog>
</div>
</template>- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/lib/components/markas/Drawer.svelte.
src/lib/components/markas/Drawer.svelte
<script lang="ts">
import type { Snippet } from "svelte";
import type { HTMLDialogAttributes } from "svelte/elements";
const dialogClass =
"fixed inset-y-0 m-0 h-dvh max-h-dvh w-full max-w-sm border-line bg-surface p-0 text-ink shadow-overlay transition-transform duration-200 ease-out backdrop:bg-ink/40 motion-reduce:transition-none";
const sides = {
right: "right-0 left-auto border-l starting:open:translate-x-full",
left: "right-auto left-0 border-r starting:open:-translate-x-full",
};
const panel = "flex h-full flex-col gap-4 p-6";
const header = "flex items-start justify-between gap-4";
const titleClass = "text-lg font-semibold text-ink";
const body = "flex-1 overflow-y-auto text-sm text-muted";
const footerClass = "flex flex-wrap justify-end gap-2";
const close =
"inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted transition-colors duration-150 ease-out hover:bg-subtle hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none";
type Props = Omit<HTMLDialogAttributes, "title" | "open"> & {
title: string;
side?: keyof typeof sides;
/** Accessible label of the close button. */
closeLabel?: string;
trigger?: Snippet;
footer?: Snippet;
children?: Snippet;
};
let {
title,
side = "right",
closeLabel = "Close",
id,
class: className,
trigger,
footer,
children,
onclose,
onclick,
...rest
}: Props = $props();
const generatedId = $props.id();
const dialogId = $derived(id ?? generatedId);
let dialog = $state<HTMLDialogElement>();
let open = $state(false);
function show() {
dialog?.showModal();
open = true;
}
function handleClose(event: Event & { currentTarget: HTMLDialogElement }) {
open = false;
onclose?.(event);
}
function handleClick(
event: MouseEvent & { currentTarget: HTMLDialogElement },
) {
if (event.target === event.currentTarget) dialog?.close();
onclick?.(event);
}
</script>
<div class="contents">
{#if trigger}
<!-- svelte-ignore a11y_click_events_have_key_events -->
<!-- svelte-ignore a11y_no_static_element_interactions -->
<div class="contents" onclick={show}>{@render trigger()}</div>
{/if}
<dialog
bind:this={dialog}
id={dialogId}
aria-labelledby={`${dialogId}-title`}
data-state={open ? "open" : "closed"}
class={[dialogClass, sides[side], className]}
onclose={handleClose}
onclick={handleClick}
{...rest}
>
<div class={panel}>
<div class={header}>
<h2 id={`${dialogId}-title`} class={titleClass}>{title}</h2>
<form method="dialog">
<button type="submit" class={close} aria-label={closeLabel}>
<svg
class="size-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<path d="M18 6 6 18M6 6l12 12" />
</svg>
</button>
</form>
</div>
<div class={body}>{@render children?.()}</div>
{#if footer}
<form method="dialog" class={footerClass}>{@render footer()}</form>
{/if}
</div>
</dialog>
</div>- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/Drawer.astro.
src/components/markas/Drawer.astro
---
import type { HTMLAttributes } from "astro/types";
const dialogClass =
"fixed inset-y-0 m-0 h-dvh max-h-dvh w-full max-w-sm border-line bg-surface p-0 text-ink shadow-overlay transition-transform duration-200 ease-out backdrop:bg-ink/40 motion-reduce:transition-none";
const sides = {
right: "right-0 left-auto border-l starting:open:translate-x-full",
left: "right-auto left-0 border-r starting:open:-translate-x-full",
};
const panel = "flex h-full flex-col gap-4 p-6";
const header = "flex items-start justify-between gap-4";
const titleClass = "text-lg font-semibold text-ink";
const body = "flex-1 overflow-y-auto text-sm text-muted";
const footerClass = "flex flex-wrap justify-end gap-2";
const close =
"inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted transition-colors duration-150 ease-out hover:bg-subtle hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none";
type Props = Omit<HTMLAttributes<"dialog">, "title" | "open"> & {
title: string;
side?: keyof typeof sides;
/** Accessible label of the close button. */
closeLabel?: string;
};
const {
title,
side = "right",
closeLabel = "Close",
id,
class: className,
...rest
} = Astro.props;
const dialogId = id ?? `markas-drawer-${crypto.randomUUID().slice(0, 8)}`;
---
<div class="contents">
{
Astro.slots.has("trigger") && (
<div class="contents" data-markas-drawer-trigger={dialogId}>
<slot name="trigger" />
</div>
)
}
<dialog
id={dialogId}
aria-labelledby={`${dialogId}-title`}
data-state="closed"
data-markas-drawer
class:list={[dialogClass, sides[side], className]}
{...rest}
>
<div class={panel}>
<div class={header}>
<h2 id={`${dialogId}-title`} class={titleClass}>{title}</h2>
<form method="dialog">
<button type="submit" class={close} aria-label={closeLabel}>
<svg
class="size-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<path d="M18 6 6 18M6 6l12 12"></path>
</svg>
</button>
</form>
</div>
<div class={body}><slot /></div>
{
Astro.slots.has("footer") && (
<form method="dialog" class={footerClass}>
<slot name="footer" />
</form>
)
}
</div>
</dialog>
</div>
<script>
// One listener per page serves every drawer, including markup added later and pages
// reached through view transitions.
const isDrawer = (node: EventTarget | null): node is HTMLDialogElement =>
node instanceof HTMLDialogElement && node.hasAttribute("data-markas-drawer");
document.addEventListener("click", (event) => {
const target = event.target as Element;
const trigger = target.closest<HTMLElement>("[data-markas-drawer-trigger]");
if (trigger) {
const dialog = document.getElementById(
trigger.dataset.markasDrawerTrigger ?? "",
);
if (isDrawer(dialog)) {
dialog.showModal();
dialog.dataset.state = "open";
}
return;
}
// A click on the dialog itself (not its content) is a click on the backdrop.
if (isDrawer(target)) target.close();
});
// The close event does not bubble, so listen in the capture phase.
document.addEventListener(
"close",
(event) => {
if (isDrawer(event.target)) event.target.dataset.state = "closed";
},
true,
);
</script>- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/app/markas/drawer.component.ts.
src/app/markas/drawer.component.ts
import {
afterNextRender,
ChangeDetectionStrategy,
Component,
computed,
type ElementRef,
input,
output,
signal,
viewChild,
} from "@angular/core";
const dialogClass =
"fixed inset-y-0 m-0 h-dvh max-h-dvh w-full max-w-sm border-line bg-surface p-0 text-ink shadow-overlay transition-transform duration-200 ease-out backdrop:bg-ink/40 motion-reduce:transition-none";
const sides = {
right: "right-0 left-auto border-l starting:open:translate-x-full",
left: "right-auto left-0 border-r starting:open:-translate-x-full",
};
const panel = "flex h-full flex-col gap-4 p-6";
const header = "flex items-start justify-between gap-4";
const titleClass = "text-lg font-semibold text-ink";
const body = "flex-1 overflow-y-auto text-sm text-muted";
const footerClass = "flex flex-wrap justify-end gap-2";
const close =
"inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted transition-colors duration-150 ease-out hover:bg-subtle hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none";
export type DrawerSide = keyof typeof sides;
let nextId = 0;
/**
* Slots: an element with the `trigger` attribute opens the drawer, an element with the `footer`
* attribute (an ng-container works) fills the action row, everything else is the body.
* Host stays out of layout; id, title, and class move to the dialog.
*/
@Component({
selector: "markas-drawer",
changeDetection: ChangeDetectionStrategy.OnPush,
host: { class: "contents", "[attr.id]": "null", "[attr.title]": "null" },
template: `
<div class="contents" (click)="show()">
<ng-content select="[trigger]" />
</div>
<dialog
#dialog
[id]="dialogId()"
[attr.aria-labelledby]="dialogId() + '-title'"
[attr.data-state]="open() ? 'open' : 'closed'"
[class]="dialogClasses()"
(close)="handleClose()"
(click)="handleClick($event)"
>
<div [class]="panel">
<div [class]="header">
<h2 [id]="dialogId() + '-title'" [class]="titleClass">
{{ title() }}
</h2>
<form method="dialog">
<button
type="submit"
[class]="close"
[attr.aria-label]="closeLabel()"
>
<svg
class="size-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<path d="M18 6 6 18M6 6l12 12" />
</svg>
</button>
</form>
</div>
<div [class]="body"><ng-content /></div>
<form
#footer
method="dialog"
[class]="footerClass"
[hidden]="!hasFooter()"
>
<ng-content select="[footer]" />
</form>
</div>
</dialog>
`,
})
export class Drawer {
readonly title = input.required<string>();
readonly side = input<DrawerSide>("right");
/** Accessible label of the close button. */
readonly closeLabel = input("Close");
readonly id = input<string>();
readonly userClass = input("", { alias: "class" });
readonly closed = output<void>();
protected readonly panel = panel;
protected readonly header = header;
protected readonly titleClass = titleClass;
protected readonly body = body;
protected readonly footerClass = footerClass;
protected readonly close = close;
protected readonly open = signal(false);
protected readonly hasFooter = signal(false);
private readonly generatedId = `markas-drawer-${nextId++}`;
protected readonly dialogId = computed(() => this.id() ?? this.generatedId);
protected readonly dialogClasses = computed(() =>
[dialogClass, sides[this.side()], this.userClass()]
.filter(Boolean)
.join(" "),
);
private readonly dialog =
viewChild.required<ElementRef<HTMLDialogElement>>("dialog");
private readonly footer =
viewChild.required<ElementRef<HTMLFormElement>>("footer");
constructor() {
// Projected content is only known after the first render.
afterNextRender(() =>
this.hasFooter.set(this.footer().nativeElement.childElementCount > 0),
);
}
/** Opens the drawer. Also callable from a template reference: drawer.show(). */
show() {
this.dialog().nativeElement.showModal();
this.open.set(true);
}
protected handleClose() {
this.open.set(false);
this.closed.emit();
}
protected handleClick(event: MouseEvent) {
// A click on the dialog itself (not its content) is a click on the backdrop.
if (event.target === event.currentTarget)
this.dialog().nativeElement.close();
}
}Usage
<x-markas.drawer title="Filter products">
<x-slot:trigger>
<x-markas.button variant="secondary">Open filters</x-markas.button>
</x-slot:trigger>
Choose a category and price range to filter the product list.
<x-slot:footer>
<x-markas.button variant="secondary" type="submit" value="cancel">Cancel</x-markas.button>
<x-markas.button type="submit" value="apply">Apply</x-markas.button>
</x-slot:footer>
</x-markas.drawer>Needs Alpine.js. Livewire 3 and 4 already ship it.
Livewire
<x-markas.drawer title="Filters" wire:model="showFilters">
...
</x-markas.drawer>wire:model binds the open state, like the modal. Closing the drawer sets the property back to false.
import { Button } from "@/components/markas/Button";
import { Drawer } from "@/components/markas/Drawer";
<Drawer
title="Filter products"
trigger={<Button variant="secondary">Open filters</Button>}
footer={
<>
<Button variant="secondary" type="submit" value="cancel">
Cancel
</Button>
<Button type="submit" value="apply">
Apply
</Button>
</>
}
onClose={(e) => console.log(e.currentTarget.returnValue)}
>
Choose a category and price range to filter the product list.
</Drawer>;<template>
<Drawer title="Filter products">
<template #trigger>
<Button variant="secondary">Open filters</Button>
</template>
Choose a category and price range to filter the product list.
<template #footer>
<Button variant="secondary" type="submit" value="cancel">Cancel</Button>
<Button type="submit" value="apply">Apply</Button>
</template>
</Drawer>
</template><script lang="ts">
import Button from "$lib/components/markas/Button.svelte";
import Drawer from "$lib/components/markas/Drawer.svelte";
</script>
<Drawer title="Filter products">
{#snippet trigger()}
<Button variant="secondary">Open filters</Button>
{/snippet}
Choose a category and price range to filter the product list.
{#snippet footer()}
<Button variant="secondary" type="submit" value="cancel">Cancel</Button>
<Button type="submit" value="apply">Apply</Button>
{/snippet}
</Drawer>---
import Button from "@/components/markas/Button.astro";
import Drawer from "@/components/markas/Drawer.astro";
---
<Drawer title="Filter products">
<Button slot="trigger" variant="secondary">Open filters</Button>
Choose a category and price range to filter the product list.
<Fragment slot="footer">
<Button variant="secondary" type="submit" value="cancel">Cancel</Button>
<Button type="submit" value="apply">Apply</Button>
</Fragment>
</Drawer>A small bundled script opens every drawer on the page. It also works after view transitions.
import { Component } from "@angular/core";
import { Button } from "./markas/button.component";
import { Drawer } from "./markas/drawer.component";
@Component({
selector: "app-filters",
imports: [Button, Drawer],
template: `
<markas-drawer title="Filter products" (closed)="onClosed()">
<button markas-button trigger variant="secondary">Open filters</button>
Choose a category and price range to filter the product list.
<ng-container footer>
<button markas-button variant="secondary" type="submit" value="cancel">
Cancel
</button>
<button markas-button type="submit" value="apply">Apply</button>
</ng-container>
</markas-drawer>
`,
})
export class Filters {
onClosed() {}
}- Use
side="left"for a drawer from the left side. - The
valueof the button that closed the drawer is available asdialog.returnValuein thecloseevent. - The close button is labelled “Close”. Translate it with
closeLabel(Blade:close-label).
Props
| Name | Type | Default | Description |
|---|---|---|---|
title | string | - | Drawer title, also used for aria-labelledby. |
side | right | left | right | Side of the screen the drawer appears from. |
trigger | slot / ReactNode / snippet | - | Element that opens the drawer when clicked. Angular: an element with the trigger attribute. |
footer | slot / ReactNode / snippet | - | Action area. Wrapped in form method=dialog, so a type=submit button closes the drawer. Angular: an element with the footer attribute. |
id | string | auto | Dialog id. Use it to open the drawer from elsewhere with showModal(). |
closeLabel | string | Close | Accessible label of the close button. |
closed | output<void> | - | Angular only. Emits when the drawer closes. |
Accessibility
- Uses dialog with showModal(), so focus stays inside and the page behind is inert.
- Escape closes the drawer and returns focus to the trigger.
- Clicking outside the panel (the backdrop) closes the drawer.
- The close button is labelled by closeLabel.
Related components
More overlay components with the same classes in every framework.
- Alert DialogModal confirmation built on the native dialog element. It needs an explicit cancel or action choice and never closes on a backdrop click.
- Command PaletteSearchable list of commands in a modal dialog, filtered as you type, with arrow key navigation and an optional Ctrl+K or Cmd+K shortcut.
- Context MenuMenu opened by right-clicking an area or pressing Shift+F10, shown at the pointer through the Popover API with WAI-ARIA Menu keyboard support.
- Dropdown MenuAction menu built on the Popover API, with keyboard navigation following the WAI-ARIA Menu Button pattern.
- Hover CardPreview card built on the Popover API, shown when a link is hovered or focused, for profiles, repositories, and other previews.
- ModalModal dialog built on the native dialog element, with focus trapping and a close button.