Die ProseCodeGroup

GitHub
Gruppieren Sie mehrere Codebeispiele in Tabbed Interfaces für einen einfachen Vergleich.

Bearbeiten

Wickeln Sie Ihre Codeblöcke um eine code-group-Komponente, um sie in Registerkarten zu gruppieren

pnpm add @nuxt/ui
::code-group

```bash [pnpm]
pnpm add @ nuxt/ui hinzufügen
```

```bash [yarn]
yarn add @ nuxt/ui hinzufügen
```

```bash [npm]
npm install @ nuxt/ui (nicht verfügbar)
```

```bash [bun]
bun add @ nuxt/ui hinzufügen
```

::
Wie die ProsePre-Komponente verarbeitet die CodeGroup Dateinamen, Symbole und Kopierschaltflächen.

API (englisch)

Props (nicht)

Prop Default Type
defaultValue
'0'
string

The default tab to select.

sync
string

Sync the selected tab with a local storage key.

modelValue
string
ui
{ root?: SlotClass; list?: SlotClass; indicator?: SlotClass; trigger?: SlotClass; triggerIcon?: SlotClass; triggerLabel?: SlotClass; }

Slots Bearbeiten

Slot Type
default
{}

Theme Bearbeiten

app.config.ts
export default defineAppConfig({
  ui: {
    prose: {
      codeGroup: {
        slots: {
          root: 'relative group *:not-first:my-0! *:not-first:static! my-5',
          list: 'relative flex items-center gap-1 border border-muted bg-default border-b-0 rounded-t-md overflow-x-auto p-2',
          indicator: 'absolute left-0 inset-y-2 w-(--reka-tabs-indicator-size) translate-x-(--reka-tabs-indicator-position) transition-[translate,width] duration-200 ease-out motion-reduce:transition-none bg-elevated rounded-md shadow-xs',
          trigger: [
            'relative inline-flex items-center gap-1.5 text-default data-[state=active]:text-highlighted hover:bg-elevated/50 px-2 py-1.5 text-sm rounded-md disabled:cursor-not-allowed disabled:opacity-75 outline-primary/25 focus-visible:outline-3',
            'transition-colors'
          ],
          triggerIcon: 'size-4 shrink-0',
          triggerLabel: 'truncate'
        }
      }
    }
  }
})
vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'

export default defineConfig({
  plugins: [
    vue(),
    ui({
      ui: {
        prose: {
          codeGroup: {
            slots: {
              root: 'relative group *:not-first:my-0! *:not-first:static! my-5',
              list: 'relative flex items-center gap-1 border border-muted bg-default border-b-0 rounded-t-md overflow-x-auto p-2',
              indicator: 'absolute left-0 inset-y-2 w-(--reka-tabs-indicator-size) translate-x-(--reka-tabs-indicator-position) transition-[translate,width] duration-200 ease-out motion-reduce:transition-none bg-elevated rounded-md shadow-xs',
              trigger: [
                'relative inline-flex items-center gap-1.5 text-default data-[state=active]:text-highlighted hover:bg-elevated/50 px-2 py-1.5 text-sm rounded-md disabled:cursor-not-allowed disabled:opacity-75 outline-primary/25 focus-visible:outline-3',
                'transition-colors'
              ],
              triggerIcon: 'size-4 shrink-0',
              triggerLabel: 'truncate'
            }
          }
        }
      }
    })
  ]
})

Changelog (englisch)

No recent changes