Modal
Terminal-style modal dialog with overlay, header, body, footer, and keyboard support.
Modal
Design lines
1<script setup>2import { ref } from 'vue'34const openRubik = ref(false)5</script>67<Button @click="openRubik = true" color="primary">Open rubik modal</Button>8<Modal v-model:open="openRubik" title="Rubik modal" design="rubik">9 Cut corners, ink bars, HUD restraint.10</Modal>Demo
Open & title
How the modal is opened and titled: the open model and the title prop.
Basic (open + title)
Minimal modal: open controls visibility and title sets the header text.
1<script setup lang="ts">2import { ref } from 'vue'3import { Button, Modal } from '@dowardev/herdrate-vue'4const isOpen = ref(false)5</script>67<template>8 <Button @click="isOpen = true" color="primary">Open modal</Button>9 <Modal v-model:open="isOpen" title="Example Modal" closable>10 This is the modal body content.11 <template #footer>12 <Button @click="isOpen = false">OK</Button>13 <Button @click="isOpen = false">Cancel</Button>14 </template>15 </Modal>16</template>Title (title)
Plain-text heading rendered in the modal header.
1<script setup lang="ts">2import { ref } from 'vue'3import { Button, Modal } from '@dowardev/herdrate-vue'4const openTitle = ref(false)5</script>67<template>8 <Button @click="openTitle = true" color="primary">Open modal</Button>9 <Modal v-model:open="openTitle" title="Modal with title" closable>10 Modal content.11 <template #footer>12 <Button @click="openTitle = false">Close</Button>13 </template>14 </Modal>15</template>Title (title slot)
Rich content that replaces the plain title prop in the header. The slot wins when both are provided.
1<script setup lang="ts">2import { ref } from 'vue'3import { Button, Modal } from '@dowardev/herdrate-vue'45const openTitleSlot = ref(false)6</script>78<template>9 <Button @click="openTitleSlot = true" color="primary">Open modal</Button>10 <Modal v-model:open="openTitleSlot" title="Prop fallback" closable>11 <template #title><span style="color:var(--accent)">★</span> Slotted title</template>12 Modal body.13 </Modal>14</template>Appearance
The props that change the modal's look: color and width.
Color (color)
Semantic color applied to the modal title in the header.
1<script setup lang="ts">2import { ref } from 'vue'3import { Button, Modal } from '@dowardev/herdrate-vue'4const openColorP = ref(false)5const openColorS = ref(false)6const openColorD = ref(false)7</script>89<template>10 <div style="display: flex; gap: 0.5rem;">11 <Button @click="openColorP = true" color="primary">Primary</Button>12 <Button @click="openColorS = true" color="success">Success</Button>13 <Button @click="openColorD = true" color="danger">Danger</Button>14 </div>15 <Modal v-model:open="openColorP" title="Primary" color="primary" closable>16 Modal with primary color.17 <template #footer>18 <Button @click="openColorP = false" color="primary">Close</Button>19 </template>20 </Modal>21 <Modal v-model:open="openColorS" title="Success" color="success" closable>22 Modal with success color.23 <template #footer>24 <Button @click="openColorS = false" color="success">Close</Button>25 </template>26 </Modal>27 <Modal v-model:open="openColorD" title="Danger" color="danger" closable>28 Modal with danger color.29 <template #footer>30 <Button @click="openColorD = false" color="danger">Close</Button>31 </template>32 </Modal>33</template>Width (width)
Width of the modal, set with any CSS unit such as ch.
1<script setup lang="ts">2import { ref } from 'vue'3import { Button, Modal } from '@dowardev/herdrate-vue'4const openWidthNarrow = ref(false)5const openWidthWide = ref(false)6</script>78<template>9 <div style="display: flex; gap: 0.5rem;">10 <Button @click="openWidthNarrow = true" color="primary">40ch</Button>11 <Button @click="openWidthWide = true" color="primary">80ch</Button>12 </div>13 <Modal v-model:open="openWidthNarrow" title="Narrow (40ch)" width="40ch" closable>14 Modal content with 40ch width.15 <template #footer>16 <Button @click="openWidthNarrow = false" color="primary">Close</Button>17 </template>18 </Modal>19 <Modal v-model:open="openWidthWide" title="Wide (80ch)" width="80ch" closable>20 Modal content with 80ch width.21 <template #footer>22 <Button @click="openWidthWide = false" color="primary">Close</Button>23 </template>24 </Modal>25</template>Closable (closable)
Shows or hides the close button (×) in the header.
1<script setup lang="ts">2import { ref } from 'vue'3import { Button, Modal } from '@dowardev/herdrate-vue'4const openClosableOn = ref(false)5const openClosableOff = ref(false)6</script>78<template>9 <div style="display: flex; gap: 0.5rem;">10 <Button @click="openClosableOn = true" color="primary">With close</Button>11 <Button @click="openClosableOff = true" color="primary">Without close</Button>12 </div>13 <Modal v-model:open="openClosableOn" title="Closable" closable>14 You can close with ×, Escape or the button below.15 <template #footer>16 <Button @click="openClosableOn = false" color="primary">Close</Button>17 </template>18 </Modal>19 <Modal v-model:open="openClosableOff" title="Not closable" :closable="false">20 You can only close with Escape or the button below.21 <template #footer>22 <Button @click="openClosableOff = false" color="primary">Close</Button>23 </template>24 </Modal>25</template>Body & footer
The two slots that fill the modal body and its action area.
Body (default slot)
Main content of the modal. Can include any HTML or Vue component.
1<script setup lang="ts">2import { ref } from 'vue'3import { Button, Modal } from '@dowardev/herdrate-vue'4const openContent = ref(false)5</script>67<template>8 <Button @click="openContent = true" color="primary">Open modal</Button>9 <Modal v-model:open="openContent" title="Varied content" closable>10 <p>This is the modal body.</p>11 <ul>12 <li>Item 1</li>13 <li>Item 2</li>14 <li>Item 3</li>15 </ul>16 <template #footer>17 <Button @click="openContent = false" color="primary">OK</Button>18 </template>19 </Modal>20</template>Footer actions (footer slot)
Action area of the modal. Typically contains confirmation or cancellation buttons.
1<script setup lang="ts">2import { ref } from 'vue'3import { Button, Modal } from '@dowardev/herdrate-vue'4const openFooter = ref(false)5</script>67<template>8 <Button @click="openFooter = true" color="primary">Open modal</Button>9 <Modal v-model:open="openFooter" title="Confirmation" closable>10 Are you sure you want to perform this action?11 <template #footer>12 <Button @click="openFooter = false" color="primary">Cancel</Button>13 <Button @click="openFooter = false" color="primary">Confirm</Button>14 </template>15 </Modal>16</template>Footer (footer)
Plain-text footer content via the footer prop. The slot wins if both are provided.
1<script setup lang="ts">2import { ref } from 'vue'3import { Button, Modal } from '@dowardev/herdrate-vue'4const openFooterProp = ref(false)5</script>67<template>8 <Button @click="openFooterProp = true" color="primary">Open modal</Button>9 <Modal v-model:open="openFooterProp" title="Footer prop" footer="Press Esc to close" closable>10 Modal body.11 </Modal>12</template>Props
open
Controls the open state of the modal (use with v-model:open / update:open).
| Type | Default | Required |
|---|---|---|
boolean | false | ❌ |
title
Title shown in the modal header. When empty, no reserved space is shown.
| Type | Default | Required |
|---|---|---|
string | '' | ❌ |
color
Semantic color of the title in the header.
| Type | Default | Required |
|---|---|---|
Color | 'primary' | ❌ |
width
Width of the modal. Accepts any CSS value: ch, px, rem, %.
| Type | Default | Required |
|---|---|---|
string | '60ch' | ❌ |
closable
Shows or hides the close button (×) in the header.
| Type | Default | Required |
|---|---|---|
boolean | true | ❌ |
footer
Plain-text footer content shown at the bottom of the modal. Overridden by the footer slot if provided.
| Type | Default | Required |
|---|---|---|
string | — | ❌ |
design
Design line (or inherit from data-design).
| Type | Default | Required |
|---|---|---|
'tuix' | 'rubik' | — (inherits from data-design) | ❌ |
Events
| Event | Payload | Description |
|---|---|---|
update:open | boolean | Emitted when the modal requests to open or close (use with v-model:open). |
close | void | Emitted when the close button is clicked or Escape is pressed. |
Slots
| Slot | Description |
|---|---|
default | Modal body, accepts any HTML or Vue component |
title | Replaces the title prop with rich content (icons, components, etc.) |
footer | Action area, typically confirmation or cancellation buttons |
CSS Custom Properties
| Token | Default | Description |
|---|---|---|
--font-mono | "JetBrains Mono", ui-monospace, monospace | Monospace font stack for code-like content (key labels, log lines, chips). |
--accent | from theme (--ctp-latte-mauve / --ctp-mocha-mauve) | Accent color, mapped from the active semantic color. |
--bg | from theme (--ctp-latte-base / --ctp-mocha-base) | Base background of the surface. |
--bg-panel | from theme (--ctp-latte-surface1 / --ctp-mocha-surface1) | Background of panel-like raised surfaces (cards, accordions). |
--border | from theme (--ctp-latte-surface0 / --ctp-mocha-surface0) | Outline and divider color for surfaces. |
--text | from theme (--ctp-latte-text / --ctp-mocha-text) | Primary text color used inside the component. |
--color-primary | from theme (--ctp-latte-mauve / --ctp-mocha-mauve) | Primary semantic color (mauve in Catppuccin). |
--color-secondary | from theme (--ctp-latte-lavender / --ctp-mocha-lavender) | Secondary semantic color (lavender in Catppuccin). |
--color-tertiary | from theme (--ctp-latte-blue / --ctp-mocha-blue) | Tertiary semantic color (blue in Catppuccin). |
--color-success | from theme (--ctp-latte-green / --ctp-mocha-green) | Success semantic color (green in Catppuccin). |
--color-warning | from theme (--ctp-latte-yellow / --ctp-mocha-yellow) | Warning semantic color (yellow in Catppuccin). |
--color-danger | from theme (--ctp-latte-red / --ctp-mocha-red) | Danger semantic color (red in Catppuccin). |
--color-light | from theme (--ctp-latte-surface1 / --ctp-mocha-rosewater) | Light semantic color (lighter contrast tone). |
--color-medium | from theme (--ctp-latte-overlay0 / --ctp-mocha-overlay2) | Medium semantic color (mid-tone). |
--color-dark | from theme (--ctp-latte-text / --ctp-mocha-subtext1) | Dark semantic color (high contrast text). |
--cp-ease | cubic-bezier(.4, 0, .2, 1) | Default easing curve for transitions. |
--shadow | none on TUIX, elevated on rubik | Elevation shadow for raised surfaces. |
Ver Theming para la convención completa.