Skip to content

Default theme ​

@ghostvue/themes provides an optional visual baseline for applications, documentation, and playground examples. Component behavior never depends on it.

Actions

Status

DraftBetaNewOverdue

Could not refresh rows

Your last saved data is still shown.

Inputs

Save with Ctrl+S or press Esc to cancel.

Everything above is @ghostvue/themes with no custom CSS. The sheet stays on default whichever theme the docs switcher selects, and the appearance toggle moves it between light and dark. To compare default with the calm, vibrant, and mono flagships, see flagship themes.

Enable the theme ​

The easy path is the themed component, which loads the stylesheet and scopes styles to that instance:

vue
<script setup lang="ts">
import { GhostButton } from '@ghostvue/themes'
</script>

<template>
  <GhostButton>Save changes</GhostButton>
</template>

To style unstyled @ghostvue/vue buttons in a region, import the stylesheet and apply ghost-theme only where the defaults should take effect:

ts
import '@ghostvue/themes/default.css'
vue
<template>
  <main class="ghost-theme">
    <GhostButton>Save changes</GhostButton>
  </main>
</template>

Buttons outside .ghost-theme and .ghost-themed-scope remain unstyled even when the stylesheet is loaded. .ghost-themed-scope is a recipe scope only; token values come from .ghost-theme / [data-ghost-theme]. This makes it possible to compare the headless primitive with the default theme or nest a flagship around themed wrappers.

Opt-in theme CSS ​

Importing anything from @ghostvue/themes loads default.css: the default palette, the shared base, and the recipe for every themed component. That is the simplest setup, but an app that renders a few themed components still ships every recipe. When CSS size matters, use the opt-in path instead: one palette, the shared base, and only the recipes your app renders.

html
<!-- index.html: the palette host is <html>, so parts that teleport to
     <body> (dialogs, drawers, menus, popovers, tooltips) inherit it. -->
<html lang="en" data-ghost-theme="calm"></html>
ts
// main.ts
import { createApp } from 'vue'

// One palette: calm.css, vibrant.css, mono.css, or tokens.css (default).
import '@ghostvue/themes/calm.css'
// Shared base every recipe needs: wrapper scopes, elevation, materials,
// gradients, motion, and spotlight recipes.
import '@ghostvue/themes/base.css'
// One recipe per themed component family the app renders.
import '@ghostvue/themes/recipes/button.css'
import '@ghostvue/themes/recipes/dialog.css'
import '@ghostvue/themes/recipes/field.css'
import '@ghostvue/themes/recipes/input.css'

import App from './App.vue'

createApp(App).mount('#app')
vue
<!-- App.vue -->
<script setup lang="ts">
import {
  GhostButton,
  GhostDialog,
  GhostDialogContent,
  GhostDialogOverlay,
  GhostDialogTitle,
  GhostDialogTrigger,
  GhostField,
  GhostFieldControl,
  GhostFieldLabel,
  GhostInput,
} from '@ghostvue/themes/components'
</script>

<template>
  <GhostField>
    <GhostFieldLabel>Workspace name</GhostFieldLabel>
    <GhostFieldControl v-slot="field">
      <GhostInput v-bind="field" />
    </GhostFieldControl>
  </GhostField>
  <GhostDialog>
    <GhostDialogTrigger :as="GhostButton">Rename</GhostDialogTrigger>
    <GhostDialogOverlay />
    <GhostDialogContent>
      <GhostDialogTitle>Rename workspace</GhostDialogTitle>
    </GhostDialogContent>
  </GhostDialog>
</template>

@ghostvue/themes/components exports exactly the same components, composables, and types as @ghostvue/themes. The only difference is that it never imports default.css, so the stylesheets you list are the only theme CSS in the build. Both paths use the same recipe files, so a component looks the same either way.

  • Recipes. @ghostvue/themes/recipes/<family>.css uses the component family name in kebab case: GhostDropdownMenu and its parts use dropdown-menu.css, and GhostRadioGroupItem uses radio-group.css. A component without a recipe stays unstyled; nothing fails at runtime.
  • Families that need two recipes. GhostDatePicker renders the calendar recipe's parts, so import both date-picker.css and calendar.css. GhostLink with appearance="button" uses the button recipe, so import button.css as well as link.css. GhostInteractiveSurface needs only base.css.
  • Prose. recipes/prose.css styles long-form HTML inside a .ghost-prose element; it has no component. See Prose.
  • Palette host. Name the palette you imported with data-ghost-theme (for tokens.css, class="ghost-theme" or data-ghost-theme="default"). Put it on <html> or <body> when the app renders overlays: dialog, drawer, command palette, menu, popover, hover card, tooltip, select, and combobox content teleport to <body> by default, and a portaled part only gets palette tokens from an ancestor. To keep the host on an app wrapper, set the part's portal-to prop to an element inside that wrapper. The all-in setup follows the same rule. Light, dark, density, and nested modes work as in the all-in setup. To switch palettes at runtime, import each one you need, or load them on demand.
  • Do not mix entries. A single import from @ghostvue/themes, whether in your code or in a library you use, loads default.css again and removes the savings. Nuxt's themed auto-imports resolve to @ghostvue/themes, so they use the all-in setup.

In a production Vite build of the packed consumer fixture (pnpm consumer:packed), with the calm palette, the all-in setup emits about 483 KB of CSS (39.1 KB gzip). The opt-in setup with the button, dialog, field, and input recipes emits about 115 KB (9.7 KB gzip). Most of the opt-in CSS is the palette itself; each recipe adds roughly 0.2 to 2 KB gzip.

Load palettes on demand ​

Each palette stylesheet is about 83 KB minified (about 5.9 KB gzip), and an app that imports every palette its theme picker offers pays for all of them on first load. Instead, keep one palette in the initial CSS and import the others with import() when the user selects them.

Keep these in the initial CSS:

  • The first-paint palette. This is the palette named by the data-ghost-theme value in your HTML. default.css already includes the default palette. In the opt-in setup, import tokens.css or the flagship you start with. Themed components read every color, size, and motion value from palette tokens, so a host whose palette has not loaded renders unstyled.
  • base.css and the recipes. They are the same for every palette, and palette sheets contain only tokens and color-scheme. Load them with the first-paint palette, either through default.css or the opt-in imports.

Load a palette before naming it on the palette host. The stylesheet must apply before the attribute changes, or the host renders without tokens until the sheet arrives:

ts
// palettes.ts
const palettes = {
  // Already in the initial CSS.
  default: () => Promise.resolve(),
  calm: () => import('@ghostvue/themes/calm.css'),
  vibrant: () => import('@ghostvue/themes/vibrant.css'),
  mono: () => import('@ghostvue/themes/mono.css'),
  // A sheet that defineTheme wrote at build time.
  acme: () => import('./themes/acme.css'),
} satisfies Record<string, () => Promise<unknown>>

export type PaletteName = keyof typeof palettes

let requested: PaletteName | undefined

export async function switchPalette(name: PaletteName): Promise<void> {
  requested = name
  // If the sheet fails to load, this rejects and the current palette stays.
  await palettes[name]()
  // A later switch started while this sheet loaded; let it win.
  if (requested !== name) return
  document.documentElement.setAttribute('data-ghost-theme', name)
}
  • Load completion. In a Vite production build, each import() above becomes a separate CSS file, and the promise resolves only after the browser has loaded it. If the file fails to load, the promise rejects and Vite dispatches vite:preloadError. In development, the promise resolves once the styles are in the page. With another bundler, check that a dynamic CSS import waits for the stylesheet. Otherwise, add a <link rel="stylesheet"> yourself and wait for its load event.
  • Repeat switches. A module loads once, so switching back to a palette resolves immediately. Loaded palettes stay in the page. Their rules match only their own data-ghost-theme value, so they do not affect other palettes.
  • Crossfades. startThemeTransition changes data-ghost-mode only. To animate a palette change, await the import first, then set the attribute inside document.startViewTransition(). The browser then never takes a snapshot while the stylesheet is still loading.
  • Nested hosts. The same order applies to a data-ghost-theme on a subtree: await the palette, then set the attribute on that element.

Server rendering and persisted choices ​

switchPalette uses document, so call it only in the browser, for example from a click handler or onMounted. During server rendering, choose the palette and its stylesheet together:

  • When the server knows the saved palette, such as from a cookie, render data-ghost-theme with that value. Also render a <link rel="stylesheet"> for its sheet in <head>. With Vite, the ?url suffix gives the sheet's built URL:

    ts
    import calmHref from '@ghostvue/themes/calm.css?url'

    A later switchPalette('calm') call may load a second copy of the same rules, which changes nothing on screen.

  • When a blocking script restores the choice from localStorage before paint, only restore a palette that is in the initial CSS. Otherwise keep the first-paint palette and call switchPalette after the app mounts. The page then paints the first-paint palette briefly, but never a host without tokens.

Button examples ​

Slot content still controls text and icons. Mark icon and loading-indicator structure with data-part:

Icon only

Square treatment with an accessible name from aria-label.

Loading and disabled

Pending actions keep their width and focus; disabled ones do not.

The markup for each case, including a custom loading indicator:

vue
<GhostButton>
  <AddIcon data-part="icon" aria-hidden="true" />
  Add item
</GhostButton>

<GhostButton icon-only aria-label="Close dialog">
  <CloseIcon data-part="icon" aria-hidden="true" />
</GhostButton>

<GhostButton loading>Saving changes</GhostButton>

<GhostButton loading>
  <ProgressIcon data-part="loading-indicator" aria-hidden="true" />
  Publishing
</GhostButton>

data-part="icon" opts icon content into theme sizing. iconOnly (or data-icon-only on the unstyled button) opts the control into a square treatment while aria-label supplies the required accessible name. SVG descendants of an explicitly marked icon wrapper fill that wrapper.

Loading overlays the preserved content, so the accessible name and button width do not change. The default spinner is replaced when slot content provides a decorative data-part="loading-indicator" element. Loading keeps the rest fill and a wait cursor; disabled uses dedicated desaturated --ghost-action-disabled-* colors (not a faded rest tone) and cursor: not-allowed. Hover and press overlays are suppressed in both cases. Loading remains focusable, so :focus-visible still draws the two-tone ring.

Variants, sizes, and layout ​

Themed visual props (or the matching data attributes on the unstyled button) keep visual decisions off the headless API. Use the preview's controls to try each variant, tone, and size:

Themed

Visual props on the @ghostvue/themes wrapper.

vue
<GhostButton>Accent solid</GhostButton>
<GhostButton variant="soft" tone="neutral" size="sm">Neutral soft</GhostButton>
<GhostButton variant="outline">Accent outline</GhostButton>
<GhostButton variant="ghost" tone="danger">Danger ghost</GhostButton>
<GhostButton tone="danger">Danger solid</GhostButton>

<GhostButton size="sm">Small</GhostButton>
<GhostButton>Medium</GhostButton>
<GhostButton size="lg">Large</GhostButton>

<GhostButton block>Full-width action</GhostButton>

variant controls treatment independently from semantic color intent. Supported values are solid, soft, outline, and ghost; omitting it selects solid. tone accepts accent, neutral, and danger; omitting it selects accent. Supported sizes are sm, md, and lg; omitting it selects md. More layouts, including a full action bar, are on GhostButton.

Form control widths ​

Themed GhostSelectTrigger, GhostNumberInput, and horizontal GhostSlider share one width rule:

  • Intrinsic by default. In a flex toolbar, a table cell, or a plain block container, a control takes its content width: the trigger fits its label, the number input fits about eight digits plus its buttons, and the slider is 12rem wide.
  • Fill inside GhostField. The field lays out as a flex column, so a control in it stretches to the field's width. A grid cell stretches it the same way.
  • block forces full width. GhostSelectTrigger, GhostNumberInput, and GhostInput accept block to fill any container.

To pick a width yourself, set inline-size through class or style on the component. It sizes the whole control, including the number input's buttons.

Kbd examples ​

Themed GhostKbd uses elevation-0 keycaps and type/space sizes, not control minimums. A slot-only instance is one keycap; a keys combination paints each nested key instead.

Themed

Keycap chrome and size on the @ghostvue/themes wrapper.

Save withCtrl+SorEscto cancel.
vue
<GhostKbd>F5</GhostKbd>
<GhostKbd :keys="['mod', 's']" />
<GhostKbd size="sm">Esc</GhostKbd>

Solid treatments paint --ghost-gradient-action-primary, --ghost-gradient-action-neutral, or --ghost-gradient-action-danger (restrained single-hue fills in default; multi-stop OKLCH gradients in vibrant), an inset hairline bevel, and the elevation-1 shadow. Hover, press, selected, and dragged are state-layer overlays (--ghost-state-layer-*) on the current tone. Press scales to --ghost-motion-press-scale and drops to the elevation-0 flush shadow, then releases with the snappy spring. The keyboard focus ring is two-tone (2px width, 2px offset) and eases in with --ghost-focus-ring-duration (instant under reduced motion). Soft, outline, and ghost rest fills use --ghost-state-mix-* instead of a gradient. The full combination table lives on GhostButton.

Light, dark, and nested modes ​

Unset data-ghost-mode follows prefers-color-scheme. Set data-ghost-mode on any subtree to override the preference; nested attributes win. .ghost-theme implies the default theme; data-ghost-theme="default" selects it on any element. Flagship sheets (calm, vibrant, mono) match data-ghost-theme only — see flagship themes and defineTheme.

Theme hosts nest too. Each element takes its palette from its nearest .ghost-theme or data-ghost-theme host, so a nested host keeps its own palette when it also sets data-ghost-mode, and its own data-ghost-density applies even under an ancestor that pins a mode. A data-ghost-mode element changes only the tokens that differ between light and dark, so it keeps the density, touch sizing, and any token overrides it inherits. The order the theme stylesheets load in does not matter. The generated rules that reach below a host use CSS @scope (Chrome and Edge 118, Safari 17.4, Firefox 146).

vue
<div class="ghost-theme">Uses the operating-system preference.</div>
<div class="ghost-theme" data-ghost-mode="dark">Forced dark.</div>
<div class="ghost-theme" data-ghost-mode="light">
  Forced light, even inside a dark ancestor.
</div>

The wrapper applies --ghost-surface-bg and --ghost-surface-fg and sets color-scheme to light dark unless data-ghost-mode pins it. Transparent outline and ghost treatments therefore always have a supported surface.

Themed instances inherit tokens from a .ghost-theme or data-ghost-mode ancestor. They do not set color-scheme themselves, so a dark playground region is not forced back to light.

Customize tokens ​

Override semantic --ghost-* properties on the same wrapper or a nested theme scope. GhostButton maps tone="accent" to action.primary, neutral to action.neutral, and danger to action.danger. The full catalog is the token catalog.

css
.product-theme {
  --ghost-action-primary-bg: #7c3aed;
  --ghost-action-primary-fg: #ffffff;
  --ghost-action-primary-gradient-from: #7c3aed;
  --ghost-action-primary-gradient-to: #5b21b6;
  --ghost-state-layer-hover: 0.08;
  --ghost-focus-ring-color: #111827;
  --ghost-focus-ring-contrast: #ffffff;
  --ghost-roundness: 0.5;
  --ghost-control-size-md-min: 3rem;
  --ghost-control-size-md-padding-inline: 1.5rem;
}

Soft, outline, and ghost rest colors mix the selected action tone into --ghost-surface-bg with color-mix(in oklch, …) using --ghost-state-mix-*. Hover and press then apply the same state-layer overlay as solid, so overriding a tone remains coherent across every treatment.

Radius and motion duration tokens are recalculated on every element from --ghost-roundness and --ghost-motion-intensity, so a wrapper rule such as --ghost-action-radius: 999px never reaches the components inside it. Scale them with those two properties (see roundness and motion), or set border-radius on one component through a class.

Internal --_ghost-* properties are implementation details and are not supported theme APIs. data-visual-state is a docs/snapshot preview hook, not a component prop.

Elevation, materials, and gradients are semantic --ghost-* variables plus documented data-elevation, data-material, and data-gradient recipes. See elevation, materials, and gradients. Motion durations, easing, and springs are --ghost-motion-* plus data-motion recipes; see motion. Pointer spotlight is --ghost-interactive-* plus a data-interactive='spotlight' recipe; see GhostInteractiveSurface. Density, type, and roundness nest through data-ghost-density and --ghost-roundness; see density, type, and roundness.

Menu and listbox rows use the small control size for the active density. Invalid Input, Textarea, and NumberInput fields use the danger border and focus ring with the default field colors.

Authored DTCG lives in packages/themes/tokens/ and is compiled by @ghostvue/themes (ADR 0007).

Icons ​

The theme ships no icon set and does not depend on an icon library (ADR 0013). Supply icons as slot content from whatever set your application uses; headless components never choose artwork.

Themed defaults are CSS-painted, not icon assets: the GhostButton and GhostSpinner loading rings, the GhostCheckbox check and indeterminate bar, and the GhostRadioGroup dot. They follow the same tokens as your icons.

  • Color. Icons inherit the control's text color when they paint with currentColor (stroke="currentColor" or fill="currentColor"), so tone, mode, disabled, and forced-colors styling apply without per-icon colors.
  • Size. --ghost-action-icon-size (default 1.1em) sizes [data-part='icon'] in GhostButton and GhostBadge and the GhostLink [data-part='external-icon']; the inner svg fills that box. --ghost-action-spinner-size and --ghost-action-spinner-width size loading rings. Both are em-based, so icons follow density and text size.
  • Replacement. Put your own markup in the documented slot. In a loading GhostButton, an element with data-part="loading-indicator" replaces the default ring; GhostLink's externalIndicator slot replaces its arrow.
css
.product-theme {
  --ghost-action-icon-size: 1.25em;
  --ghost-action-spinner-width: 3px;
}
vue
<GhostButton icon-only aria-label="Close dialog">
  <svg data-part="icon" aria-hidden="true" focusable="false" viewBox="0 0 16 16">
    <path d="M3 3l10 10M13 3L3 13" fill="none" stroke="currentColor" />
  </svg>
</GhostButton>

Decorative icons need aria-hidden="true". An icon never names a control: icon-only controls need aria-label, aria-labelledby, or GhostVisuallyHidden text. icon-only changes sizing only.

Accessibility and motion ​

The defaults include contrast-tested light and dark treatments (WCAG 2 AA is gated in pnpm contrast, including each solid gradient end stop against its *.fg; APCA Lc is advisory), a two-color keyboard focus indicator with a short entrance, density-aware control sizes with a 44px coarse-pointer floor, disabled and loading cursors, and reduced-motion handling that keeps short color and opacity feedback, drops press scale, and makes the focus ring instant.

Light and dark use two strategies. Unset data-ghost-mode follows prefers-color-scheme from CSS alone, so server rendering does not flash the opposite palette; data-ghost-mode="light" or "dark" pins a subtree (see Light, dark, and nested modes).

In forced colors (Windows High Contrast), tokens map to system colors and shadows, gradients, and glass drop away. Themed components keep every state visible: checked, selected, active, and current indicators (checkbox, radio, switch, tabs, tree, select and combobox options, calendar days, the current page) paint Highlight with HighlightText, disabled parts use GrayText, and focus rings are system-color outlines. If you restyle one of these states, check it with forced colors emulated (Chromium DevTools > Rendering > "Emulate CSS media feature forced-colors"). Applications remain responsible for testing token overrides for contrast, focus visibility, zoom, and target size in their full interface.

startThemeTransition(element, mode) is an optional helper that crossfades data-ghost-mode with the View Transitions API when it exists and reduced motion is not requested. This is a new public export.

Print ​

Theme CSS includes print defaults, so a themed page prints legibly without app-specific @media print rules:

  • A theme host with no data-ghost-mode prints the light palette, even when the system prefers dark. Nested theme hosts without their own data-ghost-mode follow it.
  • Shadow tokens (--ghost-elevation-*-shadow, --ghost-elevation-*-highlight, and the --ghost-action-* shadows) drop to a transparent zero shadow, so cards, menus, and buttons print without drop shadows.
  • The themed toast viewport and open overlays are hidden. That covers dialog, drawer, and command palette surfaces with their scrims, plus popover, hover card, tooltip, select, combobox, date picker, and dropdown, context, and menubar menus.

To opt out of the light palette, set data-ghost-mode explicitly. An explicit mode is kept in print, on the root or on any subtree:

html
<html class="ghost-theme" data-ghost-mode="dark">
  <!-- Prints dark, as on screen. -->
</html>

Browsers leave out background colors and images when printing unless the reader enables background graphics, so dark output also depends on that print setting. Hidden toasts and overlays and dropped shadows do not change with the mode. Pagination, repeated table headers, and page layout are left to the app.

Override classes directly ​

The stylesheet is published in the low-priority ghostvue-theme cascade layer, and its selectors use zero-specificity :where(). Ordinary unlayered consumer styles therefore win even when imported before the theme:

css
.product-button {
  background-color: rebeccapurple;
  border-radius: 999px;
}

Styling themed components from your app ​

Themed components accept class, style, and other attributes like any Vue component, but the element a rule needs to reach is not always the element it reaches. Three things decide whether a rule in your app applies: which element receives class, whether that element carries the attribute Vue adds for a <style scoped> block, and whether the element is still inside your app wrapper after it teleports to <body>.

Scoped styles and wrapper roots ​

Vue adds a scoped block's data-v-… attribute to the elements your template renders and to the root element of each child component. Some themed components wrap their root in another node that activates the recipe, and class and the other attributes go to the element inside it. Vue gives the scope attribute only to the outer node, so these wrappers copy it to the element that receives class. A scoped .plans { gap: 0 } on GhostRadioGroup matches the inner <fieldset>. Content parts, overlays, and the toast viewport render a portal as their root, which has no element for Vue to mark, so they put the scope attribute on the element that receives class themselves. When the themed component is the single root of your own component, the inner element also gets the scope attributes Vue passes down from your component's parents.

WrapperThemed componentsclass and attributes go toScope attribute goes toScoped .my-class rule
NoneGhostAccordion, GhostBreadcrumb, GhostCard, GhostDataTable, GhostEmptyState, GhostFileUpload, GhostInlineAlert, GhostScrollArea, GhostScrollSpy, GhostSegmentedControl, GhostSkeleton, GhostTagsInput, GhostToggleGroup, GhostTree, and parts such as tabs, menu items and radio itemsThe rootThe rootMatches
display: contents spanGhostAvatar, GhostBadge, GhostButton, GhostCheckbox, GhostCheckboxGroup, GhostField, GhostInput, GhostInteractiveSurface, GhostKbd, GhostLink, GhostMenubar, GhostPagination, GhostProgress, GhostRadioGroup, GhostSeparator, GhostSlider, GhostSpinner, GhostStepper, GhostSwitch, GhostTextarea, GhostToolbarThe inner rootspan.ghost-themed-scope and the inner rootMatches
Frame spanGhostNumberInputclass and style to the frame; other attributes to the text inputThe frameMatches
div around a tableGhostTable, GhostDataTablePreset, GhostDataTableTableThe <table>div.ghost-themed-scope and the <table>Matches
div around a code blockGhostCodeBlockThe code block rootdiv.ghost-themed-scope and the code block rootMatches
Container divGhostCalendarclass and style to the container; other attributes to the headless calendarThe containerMatches
PortalThe *Content parts of dialog, drawer, popover, hover card, tooltip, dropdown, context and menubar menus, submenus, select, combobox, command palette, and date picker; the dialog, drawer, and command palette overlays; the toast viewportThe content rootThe content root, portaled or with :portal="false"Matches
No elementThe roots GhostCollapsible, GhostCombobox, GhostCommandPalette, GhostContextMenu, GhostDatePicker, GhostDialog, GhostDrawer, GhostDropdownMenu, GhostHoverCard, GhostPopover, GhostSelect, GhostTabs, GhostToastProvider, GhostTooltipNowhere: put the class on a partNothingNot applicable

Two components split their attributes: GhostTagsInput puts class on its root and other attributes on its text input, and GhostNumberInput puts class and style on a frame around the whole control and other attributes on its text input.

The example below puts four of these side by side in one scoped layout. Each cell names the selector that reaches the component, and the source shows why:

Scoped styles on themed wrappers

RadioGroup, Toolbar, Link, and Card side by side in a scoped layout, each with the scoped selector that reaches it.

.billing__plans
.billing__actions
.billing__help Compare plans
.billing__summary
Team plan, billed monthly

To style themed components from a container you render, or without a scoped block, these also work:

  • :deep() from an element you render. .settings :deep(.plans) compiles to .settings[data-v-…] .plans, so the scope check moves to your own element and the class matches anywhere beneath it. It does not work for portaled content, which leaves your element.
  • Layout from the parent. Gap, alignment, and grid placement set on your own container still apply, because a display: contents span passes its children straight to the parent's layout.
  • An unscoped block or a global class. Use a second <style> block without scoped, or :global(.my-class), with a prefixed class name so the rule stays specific to your component.

Scoped styles and teleported content ​

Dialog, drawer, popover, hover card, tooltip, menu, select, combobox, command palette, and date picker content teleports to <body> by default. The content root still carries your scope attribute after it teleports, and with :portal="false", so a scoped rule on its class applies:

vue
<template>
  <GhostDialogContent class="booking-dialog">
    <GhostDialogTitle>Change dates</GhostDialogTitle>
    <p class="booking-dialog__summary">Two nights, one room.</p>
  </GhostDialogContent>
</template>

<style scoped>
.booking-dialog {
  inline-size: min(40rem, 100%);
}

.booking-dialog__summary {
  color: var(--ghost-text-muted);
}
</style>

The same holds for the dialog, drawer, and command palette overlays and for the toast viewport, in both the themed and the headless (@ghostvue/vue) parts. When the content part is the single root of your own component, it also gets the scope attributes Vue passes down from your component's parents.

Elements and parts you write between the content's tags, such as the title above or menu items, keep your scope attribute too. Elements a part renders for itself, such as the listbox inside select and combobox content, do not. Reach them with :deep() from the content root, for example .plan-list :deep([data-part='listbox']) with class="plan-list" on GhostSelectContent, or from an unscoped block. :deep() from an element outside the content, such as .page :deep(.booking-dialog), does not reach teleported content, because the content is no longer inside .page.

Token overrides and the palette host ​

Token overrides are inherited CSS custom properties, so they reach only the elements inside the element you set them on. An override on an app wrapper, such as .app { --ghost-type-family-sans: 'Inter', sans-serif }, styles components inside .app but not dialogs, drawers, menus, popovers, or tooltips, because those teleport to <body>, outside .app.

To reach teleported parts too, do one of these:

  • Override on the palette host. Put the palette host on <html> (see Opt-in theme CSS) and set your overrides on the same element. Theme CSS sits in the ghostvue-theme layer, so an unlayered :root rule wins:

    css
    :root {
      --ghost-roundness: 0.5;
      --ghost-type-family-sans: 'Inter', system-ui, sans-serif;
      --ghost-action-label-family: 'Inter', system-ui, sans-serif;
    }

    A typeface change needs both family tokens. --ghost-type-family-sans covers component text, but badge, button, checkbox, pagination, and toast labels read --ghost-action-label-family, which has its own value and keeps the system font if you leave it out. A theme generated with defineTheme() sets both from one fontFamily input; see Set the typeface.

  • Keep the content inside the wrapper. Set the part's portal-to prop to an element inside the wrapper so the content stays in the subtree that holds the override.

The same applies to data-ghost-mode, data-ghost-density, and a nested data-ghost-theme set on an app wrapper: teleported content takes its tokens from where it lands, not from the component that opened it.