Skip to content

Customization

Vue API Playground is designed to work out of the box with VitePress. For standalone Vue 3 apps or custom setups, you have full control over the look and feel.

CSS Variables

The component uses CSS custom properties with a --vap-* prefix. Override them at any scope — globally or per-instance.

Full variable reference

VariableDescriptionDefault
--vap-brandPrimary/accent color (buttons, focus rings)#3eaf7c
--vap-textMain text color#2c3e50
--vap-text-lightSecondary text (response time, labels)#476582
--vap-borderBorder color for tables, inputs, response area#eaecef
--vap-bgBackground color for inputs#ffffff
--vap-bg-softSoft background (table headers, status bar)#f3f4f6
--vap-code-bgCode block background#1e1e1e
--vap-code-textCode block text color#d4d4d4
--vap-successSuccess badge color (2xx status)#42b983
--vap-dangerError badge color (4xx/5xx status)#cc0000
--vap-warningWarning badge color (PUT/PATCH method)#e7c000
--vap-infoInfo badge color (GET method)same as brand
--vap-radiusBorder radius for inputs, buttons, badges6px
--vap-font-sizeBase font size0.9rem

Global override

Apply to all playground instances:

css
:root {
  --vap-brand: #6366f1;
  --vap-text: #1a1a1a;
  --vap-border: #e5e7eb;
  --vap-bg: #ffffff;
  --vap-bg-soft: #f9fafb;
  --vap-radius: 8px;
}

Per-instance override

Scope variables to a specific wrapper:

vue
<template>
  <div class="custom-playground">
    <VueApiPlayground url="https://api.example.com/posts" method="get" />
  </div>
</template>

<style>
.custom-playground {
  --vap-brand: #e11d48;
  --vap-radius: 12px;
  --vap-font-size: 0.85rem;
}
</style>

Dark mode

For apps with a dark mode toggle, override the variables under your dark class or media query:

css
:root {
  --vap-text: #1a1a1a;
  --vap-bg: #ffffff;
  --vap-bg-soft: #f3f4f6;
  --vap-border: #e5e7eb;
  --vap-code-bg: #1e1e1e;
  --vap-code-text: #d4d4d4;
}

.dark,
[data-theme='dark'] {
  --vap-text: #e5e7eb;
  --vap-bg: #1a1a2e;
  --vap-bg-soft: #16213e;
  --vap-border: #334155;
  --vap-code-bg: #0f172a;
  --vap-code-text: #e2e8f0;
}

TIP

When used inside VitePress, the component automatically inherits dark mode colors from the theme. No extra configuration needed.

How the CSS cascade works

The component resolves each color through three fallback levels:

--vap-*  →  --vp-c-*  →  hardcoded default
(user)      (VitePress)    (standalone)

This means:

  • In VitePress — component reads --vp-c-brand-1, --vp-c-text-1, etc. from the theme
  • Standalone — hardcoded defaults kick in (green accent, dark text, light background)
  • --vap-* always wins — if you set it, it overrides everything else

Custom styles

If CSS variables aren't enough, you can target the component's CSS classes directly. All classes are prefixed with vap- to avoid collisions.

Class reference

ClassElement
.vap-playgroundPlayground root container
.vap-playground__methodPlayground method heading
.vap-playground__urlPlayground URL heading
.vap-requestApiRequest root container
.vap-request__methodApiRequest method heading
.vap-request__importcURL import <details>
.vap-responseApiResponse root / wrapper
.vap-response__barStatus + time + buttons bar
.vap-response__statusStatus text + badge
.vap-response__timeResponse time display
.vap-response__sizeResponse payload size
.vap-response__headersResponse headers <details>
.vap-tableShared table (headers, data)
.vap-inputShared input fields
.vap-btnButton base class
.vap-btn--primaryExecute button
.vap-btn--secondaryCopy / cURL buttons
.vap-codeCode/response <pre> block
.vap-badgeBadge base class
.vap-badge--success2xx status / POST badge
.vap-badge--danger4xx/5xx status / DELETE badge
.vap-badge--warningPUT/PATCH method badge
.vap-badge--infoGET method badge
.vap-spinnerLoading spinner
.vap-json-keyJSON key in highlighted output
.vap-json-stringJSON string value
.vap-json-numberJSON number value
.vap-json-boolJSON boolean/null value

Example: custom button style

css
.vap-btn--primary {
  background-color: #6366f1;
  border-color: #6366f1;
  border-radius: 9999px;
  font-weight: 600;
}

Without styles

You can skip the default styles entirely and write your own:

ts
import { Playground } from 'vue-api-playground'
// Don't import 'vue-api-playground/styles'

The component renders semantic HTML with vap- prefixed classes. Style them however you want.

Released under the MIT License.