Command
Renders a terminal command with a variant for each package manager.
npm install renounpnpm add renounyarn add renounbun add renounimport { Command } from 'renoun' export function InstallExample() { return <Command variant="install">renoun</Command> }
Local Storage
The Command component uses local storage for the package manager preference and will use a small script hoisted to the root of the page to set the package manager on load. This is done to avoid any flashing from state changes when a local storage value is found.
Examples
Install Dev Example
View Sourcenpm install --save-dev @types/react @types/react-dompnpm add --save-dev @types/react @types/react-domyarn add --dev @types/react @types/react-dombun add --dev @types/react @types/react-domimport { Command } from 'renoun' export function InstallDevExample() { return <Command variant="install-dev">@types/react @types/react-dom</Command> }
Run Example
View Sourcenpm run devpnpm devyarn devbun run devimport { Command } from 'renoun' export function RunExample() { return <Command variant="run">dev</Command> }
Exec Example
View Sourcenpx create-renoun --example=docspnpm dlx create-renoun --example=docsyarn dlx create-renoun --example=docsbunx create-renoun --example=docsimport { Command } from 'renoun' export function ExecExample() { return <Command variant="exec">create-renoun --example=docs</Command> }
Create Example
View Sourcenpm create renounpnpm create renounyarn create renounbun create renounimport { Command } from 'renoun' export function CreateExample() { return <Command variant="create">renoun</Command> }
API Reference
Type
"install" | "install-dev" | "run" | "exec" | "create"Properties
| Property | Type | Modifiers |
|---|---|---|
| variant? | CommandVariant | — |
The type of command to render across package managers. | ||
| children | React.ReactNode | — |
Content used as the subject: packages (install), script (run), binary (exec), or template (create). | ||
| shouldValidate? | boolean | — |
Whether the command should validate the npm package before rendering. | ||
| css? | { container?: CSSObject; tabs?: CSSObject; tabButton?: CSSObject; tabPanel?: CSSObject; copyButton?: CSSObject; code?: CSSObject; } | — |
Override styles for each part of the component. | ||
| className? | { container?: string; tabs?: string; tabButton?: string; tabPanel?: string; copyButton?: string; code?: string; } | — |
Override class names for each part of the component. | ||
| style? | { container?: React.CSSProperties; tabs?: React.CSSProperties; tabButton?: React.CSSProperties; tabPanel?: React.CSSProperties; copyButton?: React.CSSProperties; code?: React.CSSProperties; } | — |
Inline style overrides for each part of the component. | ||
Renders a terminal command with a variant for each package manager.
Properties
CommandPropsReturns
React.JSX.Element