Logoshadcn-docs-template
DocsDemo
Sections
  • Get Started
Getting Started
  • Introduction
  • Installation
Customization
  • Customizing the Template
  • MDC Components
  • Composables
  • Writing Documentation
Components
  • DocTabs
  • Callout
  • ComponentPreview
  • CommandMenu
  • CopyButton
  • DocsSidebar
  • DocsTableOfContents
  • PageHeader
  • SiteHeader
  • CopyCodeButton
  • DocsCopyPage
  • CodeBlockCommand
  • CommandMenuItem
  • CommandMenuKbd
  • GitHubLink
  • LucideIcon
  • MainNav
  • MobileNav
  • ModeSwitcher
  • PageHeaderDescription
  • PageHeaderHeading
  • SiteBody
  • SiteConfig
  • SiteFooter
  • OgImage (Custom)

CodeBlockCommand

PreviousNext

A component that displays code commands with package manager tabs (npm, yarn, pnpm, bun).

The CodeBlockCommand component automatically converts installation commands to different package managers and displays them in tabs.

Usage

<script setup lang="ts">
import { CodeBlockCommand } from '@/components/CodeBlockCommand'
</script>

<template>
  <CodeBlockCommand code="npm install shadcn-vue" />
</template>

Features

Automatic Conversion

The component automatically converts commands:

  • npm install → yarn add, pnpm add, bun add
  • npx create-* → yarn create, pnpm create, bun create
  • npx → yarn dlx, pnpm dlx, bunx
  • npm run → yarn, pnpm, bun

Package Manager Selection

Users can switch between package managers using tabs, and their selection is saved in useConfig().

API Reference

CodeBlockCommand

PropTypeDescription
codestringThe command code to display and convert

Supported Commands

  • npm install <package>
  • npx create-<template>
  • npm create <template>
  • npx <command>
  • npm run <script>

Styling

The component includes:

  • Terminal icon indicator
  • Syntax highlighting for bash
  • Copy button overlay
  • Responsive tab layout
DocsCopyPageCommandMenuItem

On This Page

UsageFeaturesAutomatic ConversionPackage Manager SelectionAPI ReferenceCodeBlockCommandSupported CommandsStyling
© shadcn-vue.com