Components
Snippet
A short command or line of code in a box, with a button that copies it.
Introduction
Snippet is for the thing a reader is about to paste into a terminal: npm install centerui, a git clone, a one-line config. It keeps it short and monospaced in a small box, and puts a copy button at the end so nobody has to select it by hand.
- A
$comes before every line, and it is not selected, read out or copied. Change it, or hide it. - Pass an array for several lines. They are copied with line breaks, ready to paste as a script.
- The button becomes a check mark for a moment after it copies, and the copy is announced to screen readers. If the browser refuses the clipboard, it falls back to the older way of copying.
- A long line scrolls sideways, or wraps with
isWrapped. SnippetTabsshows the same command forbun,npm,yarnandpnpm, one tab each, and can remember which one the reader picked.
For longer code with several files or languages, use a code block. The copy logic is a hook, useCopyToClipboard, that you can use on its own.
Installation
centerUI has no CLI or registry yet: components are copied into your project. Snippet uses Button for its copy button.
# bun
bun add tailwind-variants tailwind-merge clsx
# pnpm
pnpm add tailwind-variants tailwind-merge clsx
# npm
npm install tailwind-variants tailwind-merge clsxAdd Button first (see its Manual installation), then follow the steps below.
Manual installation
Copy these files into your project and keep the paths, or adjust the imports.
1. Add the hooks and the styles
src/types/use-copy-to-clipboard.tsShow code
import { useCallback, useEffect, useRef, useState } from "react";
// The old way, for when the Clipboard API is missing or refuses (an insecure
// page, a permission policy): select a hidden textarea and copy the selection.
function copyWithSelection(text: string) {
const area = document.createElement("textarea");
area.value = text;
area.setAttribute("readonly", "");
area.style.position = "fixed";
area.style.opacity = "0";
document.body.appendChild(area);
area.select();
try {
return document.execCommand("copy");
} catch {
return false;
} finally {
area.remove();
}
}
/**
* Copies text to the clipboard, and says for a moment that it did. `copy`
* resolves to whether it worked, and `isCopied` turns `true` and goes back to
* `false` after `timeout` milliseconds.
*/
export function useCopyToClipboard(timeout = 2000) {
const [isCopied, setIsCopied] = useState(false);
const timer = useRef<number | undefined>(undefined);
useEffect(() => () => window.clearTimeout(timer.current), []);
const copy = useCallback(
async (text: string) => {
let ok = false;
try {
await navigator.clipboard.writeText(text);
ok = true;
} catch {
ok = copyWithSelection(text);
}
if (ok) {
setIsCopied(true);
window.clearTimeout(timer.current);
timer.current = window.setTimeout(() => setIsCopied(false), timeout);
}
return ok;
},
[timeout],
);
return { copy, isCopied };
}src/types/snippet-styles.tsShow code
import { tv } from "tailwind-variants";
// Styles for Snippet: a short command in a box, with a copy button at the end.
// `body` is the code and the button; a Snippet is a box around one body, and
// SnippetTabs is a box around a row of tabs and one body for each tab.
export const snippetStyles = tv({
slots: {
root: "inline-flex max-w-full rounded-lg font-mono",
body: "flex min-w-0 flex-1 items-center gap-3",
scroller: [
"min-w-0 flex-1 overflow-x-auto rounded-sm outline-none",
"[scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
"focus-visible:ring-2 focus-visible:ring-ring",
],
line: "flex gap-2 whitespace-pre",
symbol: "select-none opacity-60",
copy: "shrink-0",
},
variants: {
variant: {
outline: { root: "border bg-transparent text-fg" },
secondary: { root: "bg-muted text-fg" },
primary: { root: "bg-primary text-primary-fg" },
},
size: {
sm: { body: "py-1.5 pr-1.5 pl-3 text-xs" },
md: { body: "py-2 pr-2 pl-3.5 text-sm" },
lg: { body: "py-2.5 pr-2.5 pl-4 text-base" },
},
// Break long lines instead of scrolling them sideways.
isWrapped: {
true: { line: "whitespace-pre-wrap break-all" },
false: {},
},
hasCopy: {
true: {},
false: { body: "pr-3.5" },
},
},
defaultVariants: {
variant: "outline",
size: "md",
isWrapped: false,
hasCopy: true,
},
});
// Styles for SnippetTabs: the box, the row of tabs, and a panel per tab.
export const snippetTabsStyles = tv({
slots: {
root: "flex w-fit max-w-full min-w-72 flex-col overflow-hidden rounded-lg font-mono",
list: "flex items-end gap-1 border-b px-2 font-sans",
tab: [
"relative cursor-pointer whitespace-nowrap rounded-t-md font-medium text-muted-fg outline-none transition-colors",
"data-hovered:text-fg",
"data-selected:text-fg",
"data-focus-visible:ring-2 data-focus-visible:ring-ring data-focus-visible:ring-inset",
"data-disabled:cursor-not-allowed data-disabled:opacity-50",
// The line that marks the selected tab, sitting on the border below.
"after:absolute after:inset-x-2 after:-bottom-px after:h-0.5 after:rounded-full after:bg-fg after:opacity-0 after:transition-opacity",
"data-selected:after:opacity-100",
],
panel: "outline-none",
},
variants: {
variant: {
outline: { root: "border bg-transparent text-fg" },
secondary: { root: "bg-muted text-fg", list: "border-border/60" },
},
size: {
sm: { tab: "px-2 py-1.5 text-xs" },
md: { tab: "px-2.5 py-2 text-sm" },
lg: { tab: "px-3 py-2.5 text-base" },
},
},
defaultVariants: { variant: "outline", size: "md" },
});For tabs, also add these. The first is what a SnippetTabs tells its panels, the second remembers the selected tab, and the third builds the commands for each package manager. Skip them if you only need Snippet, and remove the tabs from the file.
src/types/snippet-context.tsShow code
import { createContext, useContext } from "react";
import type { SnippetBodyOptions } from "@/components/ui/snippet/snippet";
/** What SnippetTabs passes down to the panels inside it. */
export type SnippetTabsContextValue = SnippetBodyOptions & {
variant: "outline" | "secondary";
size: "sm" | "md" | "lg";
/** The name of the row of tabs. */
label: string;
};
const SnippetTabsContext = createContext<SnippetTabsContextValue | null>(null);
export const SnippetTabsProvider = SnippetTabsContext.Provider;
/** The enclosing SnippetTabs' settings, or an error outside of one. */
export function useSnippetTabs() {
const context = useContext(SnippetTabsContext);
if (!context) {
throw new Error("Snippet tab parts must be used inside <SnippetTabs>.");
}
return context;
}src/types/use-stored-selection.tsShow code
import { useCallback, useSyncExternalStore } from "react";
// Every component that stores under a key is told when another one does, so
// two of them on a page stay on the same choice. The `storage` event covers
// other tabs.
const listeners = new Set<() => void>();
function subscribe(listener: () => void) {
listeners.add(listener);
window.addEventListener("storage", listener);
return () => {
listeners.delete(listener);
window.removeEventListener("storage", listener);
};
}
function read(key: string) {
try {
return window.localStorage.getItem(key);
} catch {
// Storage can be blocked (a private window, site data turned off).
return null;
}
}
/**
* A choice remembered in `localStorage` and shared between everything that
* uses the same key. It is `null` on the server and until something is
* stored, so render a default meanwhile. Without a key it does nothing.
*/
export function useStoredSelection(storageKey: string | undefined) {
const stored = useSyncExternalStore(
subscribe,
() => (storageKey ? read(storageKey) : null),
() => null,
);
const store = useCallback(
(value: string) => {
if (!storageKey) return;
try {
window.localStorage.setItem(storageKey, value);
} catch {
// Not remembered, but the choice still applies to this page.
}
for (const listener of listeners) listener();
},
[storageKey],
);
return [stored, store] as const;
}src/types/package-commands.tsShow code
export type PackageManager = "bun" | "npm" | "yarn" | "pnpm";
export type PackageCommands = Record<PackageManager, string>;
/**
* The command to add a package, for each package manager. Pass it to
* `SnippetTabs` as `commands`.
*
* installCommands("zod", { dev: true })
* // { bun: "bun add -d zod", npm: "npm install -D zod", yarn: "yarn add -D zod", pnpm: "pnpm add -D zod" }
*/
export function installCommands(
packages: string,
options: { dev?: boolean; global?: boolean } = {},
): PackageCommands {
const { dev = false, global = false } = options;
return {
bun: `bun add ${global ? "-g " : dev ? "-d " : ""}${packages}`,
npm: `npm install ${global ? "-g " : dev ? "-D " : ""}${packages}`,
yarn: global
? `yarn global add ${packages}`
: `yarn add ${dev ? "-D " : ""}${packages}`,
pnpm: `pnpm add ${global ? "-g " : dev ? "-D " : ""}${packages}`,
};
}
/**
* The command to run a package without installing it first, for each
* package manager: `bunx`, `npx`, `yarn dlx` and `pnpm dlx`.
*/
export function executeCommands(command: string): PackageCommands {
return {
bun: `bunx ${command}`,
npm: `npx ${command}`,
yarn: `yarn dlx ${command}`,
pnpm: `pnpm dlx ${command}`,
};
}
/** The command to run a script of `package.json`, for each package manager. */
export function runCommands(script: string): PackageCommands {
return {
bun: `bun run ${script}`,
npm: `npm run ${script}`,
yarn: `yarn ${script}`,
pnpm: `pnpm ${script}`,
};
}2. Add the Snippet file
src/components/ui/snippet/snippet.tsxShow code
"use client";
import { type ReactNode, useState } from "react";
import {
Tab as AriaTab,
TabList as AriaTabList,
TabPanel as AriaTabPanel,
Tabs as AriaTabs,
} from "react-aria-components";
import { CheckIcon, CopyIcon } from "@/components/icons";
import { Button } from "@/components/ui/button/button";
import { cn } from "@/lib/cn";
import { SnippetTabsProvider, useSnippetTabs } from "@/types/snippet-context";
import { snippetStyles, snippetTabsStyles } from "@/types/snippet-styles";
import { useCopyToClipboard } from "@/types/use-copy-to-clipboard";
import { useStoredSelection } from "@/types/use-stored-selection";
const copySize = { sm: "xxs", md: "xs", lg: "sm" } as const;
/** What the code and its copy button take, alone or in a tab. */
export interface SnippetBodyOptions {
/** What comes before every line. Defaults to `$`. */
symbol?: ReactNode;
/** Leave the symbol out, for code that is not typed in a terminal. */
hideSymbol?: boolean;
/** Leave the copy button out. */
hideCopyButton?: boolean;
/** Called with the text that was copied. */
onCopy?: (text: string) => void;
/** How long the button shows that it copied, in milliseconds. Defaults to 2000. */
timeout?: number;
/** Break long lines instead of scrolling them sideways. */
isWrapped?: boolean;
/** Names the button. Defaults to "Copy". */
copyLabel?: string;
/** Names the button after it copied. Defaults to "Copied". */
copiedLabel?: string;
}
interface SnippetBodyProps extends SnippetBodyOptions {
lines: string[];
copyValue?: string;
variant: "outline" | "secondary" | "primary";
size: "sm" | "md" | "lg";
}
// The lines of code and the copy button. A Snippet puts a box around one of
// these, and a SnippetTabPanel shows one inside the tabs' box.
function SnippetBody({
lines,
copyValue,
variant,
size,
symbol = "$",
hideSymbol = false,
hideCopyButton = false,
onCopy,
timeout,
isWrapped = false,
copyLabel = "Copy",
copiedLabel = "Copied",
}: SnippetBodyProps) {
const styles = snippetStyles({
size,
isWrapped,
hasCopy: !hideCopyButton,
});
const { copy, isCopied } = useCopyToClipboard(timeout);
async function onPress() {
const text = copyValue ?? lines.join("\n");
if (await copy(text)) onCopy?.(text);
}
return (
<div className={styles.body()}>
{/* A long command scrolls sideways, so a keyboard user has to be able to focus it to scroll it. */}
{/* biome-ignore lint/a11y/noNoninteractiveTabindex: a scroll container has to be focusable to be scrolled with the keyboard */}
<pre tabIndex={0} className={styles.scroller()}>
<code>
{lines.map((line, i) => (
// biome-ignore lint/suspicious/noArrayIndexKey: lines are a fixed list and never reorder
<span key={i} className={styles.line()}>
{hideSymbol ? null : (
<span aria-hidden="true" className={styles.symbol()}>
{symbol}
</span>
)}
<span>{line}</span>
</span>
))}
</code>
</pre>
{hideCopyButton ? null : (
<>
<Button
isIcon
variant={variant === "primary" ? "secondary" : "ghost"}
size={copySize[size]}
aria-label={isCopied ? copiedLabel : copyLabel}
onPress={onPress}
className={styles.copy()}
>
{isCopied ? <CheckIcon /> : <CopyIcon />}
</Button>
<output className="sr-only">{isCopied ? copiedLabel : ""}</output>
</>
)}
</div>
);
}
const toLines = (children: string | string[]) =>
Array.isArray(children) ? children : [children];
export interface SnippetProps extends SnippetBodyOptions {
/** The command or code. An array is one line for each item. */
children: string | string[];
/**
* The text to copy, when it is not the text shown. Defaults to the lines
* joined with a line break, without the symbol.
*/
copyValue?: string;
variant?: "outline" | "secondary" | "primary";
size?: "sm" | "md" | "lg";
className?: string;
}
/**
* A short command or line of code in a box, with a button that copies it. Made
* for what a reader is going to paste into a terminal, such as
* `npm install centerui`, so the `$` in front is not selected or copied.
* Pass an array for several lines.
*
* The button changes to a check mark for a moment after it copies, and the
* copy is announced to screen readers. For the same command in several
* package managers, use `SnippetTabs`.
*
* @example
* <Snippet>npm install react-aria-components</Snippet>
* <Snippet>{["git clone repo", "cd repo", "bun install"]}</Snippet>
*/
export function Snippet({
children,
copyValue,
variant = "outline",
size = "md",
className,
...options
}: SnippetProps) {
const styles = snippetStyles({ variant });
return (
<div className={cn(styles.root(), className)}>
<SnippetBody
lines={toLines(children)}
copyValue={copyValue}
variant={variant}
size={size}
{...options}
/>
</div>
);
}
export interface SnippetTabsProps extends SnippetBodyOptions {
/**
* A `SnippetTabList` and a `SnippetTabPanel` for each of its tabs. Leave it
* out when you pass `commands`.
*/
children?: ReactNode;
/**
* A shortcut for the common case: one tab for each key, showing its
* command. The keys are the ids and the names of the tabs, in this order.
* `installCommands("zod")` gives one for each package manager.
*/
commands?: Record<string, string | string[]>;
/** The tab shown first, when the selection is not controlled. Defaults to the first tab. */
defaultSelectedKey?: string;
/** The tab shown, for a controlled selection. */
selectedKey?: string;
onSelectionChange?: (key: string) => void;
/**
* Remember the tab in `localStorage` under this name, and keep every
* SnippetTabs with the same name on the same tab: pick pnpm once and every
* install command on the page shows pnpm, on the next visit too. The tabs
* need the same ids everywhere.
*/
storageKey?: string;
variant?: "outline" | "secondary";
size?: "sm" | "md" | "lg";
/** Names the row of tabs for screen readers. Defaults to "Commands". */
"aria-label"?: string;
className?: string;
}
/**
* The same command for several tools, one tab each: `bun add`, `npm install`,
* `yarn add` and `pnpm add`. Built on react-aria's Tabs, so the arrow keys move
* between the tabs and the panel of the selected one is shown.
*
* Pass `commands` for the usual case, or compose it from `SnippetTabList`,
* `SnippetTab` and `SnippetTabPanel` for other kinds of tabs, such as
* languages or files.
*
* @example
* <SnippetTabs commands={installCommands("zod")} storageKey="package-manager" />
*/
export function SnippetTabs({
children,
commands,
defaultSelectedKey,
selectedKey,
onSelectionChange,
storageKey,
variant = "outline",
size = "md",
"aria-label": label = "Commands",
className,
...options
}: SnippetTabsProps) {
const styles = snippetTabsStyles({ variant, size });
const [stored, store] = useStoredSelection(storageKey);
const [inner, setInner] = useState(
defaultSelectedKey ?? (commands ? Object.keys(commands)[0] : undefined),
);
// A remembered tab that this one does not have is not used.
const remembered =
stored && (!commands || Object.hasOwn(commands, stored))
? stored
: undefined;
const selected = selectedKey ?? remembered ?? inner;
return (
<AriaTabs
// Always controlled, so the tab can change when a remembered one arrives.
// No tab yet is `null`, and react-aria then selects the first one.
selectedKey={(selected ?? null) as string | undefined}
onSelectionChange={(key) => {
const next = String(key);
setInner(next);
store(next);
onSelectionChange?.(next);
}}
className={cn(styles.root(), className)}
>
<SnippetTabsProvider value={{ ...options, variant, size, label }}>
{commands ? (
<>
<SnippetTabList>
{Object.keys(commands).map((key) => (
<SnippetTab key={key} id={key}>
{key}
</SnippetTab>
))}
</SnippetTabList>
{Object.entries(commands).map(([key, command]) => (
<SnippetTabPanel key={key} id={key}>
{command}
</SnippetTabPanel>
))}
</>
) : (
children
)}
</SnippetTabsProvider>
</AriaTabs>
);
}
export interface SnippetTabListProps {
/** The `SnippetTab`s. */
children: ReactNode;
/** Overrides the name given to `SnippetTabs`. */
"aria-label"?: string;
className?: string;
}
/** The row of tabs on top of the box. */
export function SnippetTabList({
children,
className,
...props
}: SnippetTabListProps) {
const { variant, size, label } = useSnippetTabs();
const styles = snippetTabsStyles({ variant, size });
return (
<AriaTabList
aria-label={props["aria-label"] ?? label}
className={cn(styles.list(), className)}
>
{children}
</AriaTabList>
);
}
export interface SnippetTabProps {
/** Ties the tab to its `SnippetTabPanel`. */
id: string;
children: ReactNode;
isDisabled?: boolean;
className?: string;
}
/** One tab. Its `id` is the `id` of the panel it shows. */
export function SnippetTab({
id,
children,
isDisabled,
className,
}: SnippetTabProps) {
const { variant, size } = useSnippetTabs();
const styles = snippetTabsStyles({ variant, size });
return (
<AriaTab
id={id}
isDisabled={isDisabled}
className={cn(styles.tab(), className)}
>
{children}
</AriaTab>
);
}
export interface SnippetTabPanelProps extends SnippetBodyOptions {
/** The `id` of the tab that shows it. */
id: string;
/** The command or code of the tab. An array is one line for each item. */
children: string | string[];
/** The text to copy, when it is not the text shown. */
copyValue?: string;
className?: string;
}
/**
* The command of one tab. It takes the settings of the `SnippetTabs` around
* it (symbol, wrapping, labels...), and any of them can be set again here.
*/
export function SnippetTabPanel({
id,
children,
copyValue,
className,
...options
}: SnippetTabPanelProps) {
const { variant, size, label: _label, ...inherited } = useSnippetTabs();
const styles = snippetTabsStyles({ variant, size });
return (
<AriaTabPanel id={id} className={cn(styles.panel(), className)}>
<SnippetBody
lines={toLines(children)}
copyValue={copyValue}
variant={variant}
size={size}
{...inherited}
{...options}
/>
</AriaTabPanel>
);
}It imports CopyIcon and CheckIcon from @/components/icons. Add those icons, or swap them for your own.
3. Use it
import {
Snippet,
SnippetTab,
SnippetTabList,
SnippetTabPanel,
SnippetTabs,
} from "@/components/ui/snippet/snippet";
import { installCommands } from "@/types/package-commands";Anatomy
A box with the lines of code and a copy button.
<Snippet>{["git clone https://github.com/you/repo", "cd repo"]}</Snippet>| Part | Rendered as | Notes |
|---|---|---|
| Snippet | div | The box. Fits its content, up to the width of its parent. |
| Code | pre and code | One line for each item. Long lines scroll sideways, and the area can be focused to scroll it with the keyboard. |
| Symbol | span, hidden from screen readers | The $ before each line. It cannot be selected and is not copied. |
| Copy button | Button | Copies the lines. It turns into a check mark for two seconds, and the copy is announced to screen readers. |
| SnippetTabs | div (Tabs) | Optional. A box around a row of tabs and the command of the selected one. |
| SnippetTabList / SnippetTab | tablist / tab | The row of tabs, one for each tool. The arrow keys move between them. |
| SnippetTabPanel | tabpanel | The command of one tab, with its own copy button. |
Examples
Press the copy button and paste somewhere to see what was copied.
Usage
npm install react-aria-componentsMultiple lines
An array is one line for each item. The copy has a line break between them, and no symbols.
git clone https://github.com/you/centeruicd centeruibun installbun devSymbol
The symbol is $ by default. Set another for another shell, or leave it out for code that is not typed in a terminal.
Get-Processapt install nodejsconst answer = 42;Variants
npm install centeruinpm install centeruinpm install centeruiSizes
npm install centeruinpm install centeruinpm install centeruiLong lines
By default a line that does not fit scrolls sideways, and the area can be focused to scroll it with the keyboard. With isWrapped it breaks over several lines instead.
npx create-next-app@latest my-app --typescript --tailwind --eslint --app --src-dir --import-alias '@/*' --use-bunnpx create-next-app@latest my-app --typescript --tailwind --eslint --app --src-dir --import-alias '@/*' --use-bunCopy value
copyValue is what goes to the clipboard when it is not what is shown, for example a command with a version.
npm install @you/centeruiOn copy
onCopy runs after the text was copied, with the text. It does not run when the browser refuses the copy.
bun add react-aria-componentsNothing copied yet.
Labels
The name of the button, and what it says after copying, for screen readers. Translate them for your language.
npm install centeruiTabs
The same command for several tools. Choose a tab, then copy the command under it.
Package managers
installCommands gives the command to add a package for bun, npm, yarn and pnpm. Pass it to commands and each becomes a tab. The arrow keys move between the tabs.
bun add react-aria-componentsCommand helpers
Three helpers build the commands: to add a package (with dev and global options), to run it once without installing, and to run a script.
bun add -d zodbunx shadcn@latest initbun run devCustom tabs
commands takes any keys, not only package managers. An array is several lines.
git clone https://github.com/you/centeruicd centeruiCompose the tabs
For names that are not the id, or a panel with its own settings, build the tabs from their parts. Each SnippetTab is tied to a SnippetTabPanel by id, and a panel can set its own symbol or copy value.
const sum = (a: number, b: number) => a + b;Remember the choice
With a storageKey, the selected tab is kept in the browser, and every SnippetTabs with the same key follows it. Choose pnpm in one, and the other changes too, and so does the next visit. The tabs need the same ids everywhere, which the package commands do.
bun add react-aria-componentsbun run devVariants and sizes
Outline and secondary, in three sizes. The settings of the snippet, such as isWrapped and the symbol, work on the tabs too.
bun run devbun run devControlled tabs
Keep the tab in your own state with selectedKey and onSelectionChange.
pnpm add zodselectedKey: pnpm
Component API
Snippet takes the props below.
Snippet
| Prop | Type | Default |
|---|---|---|
| children | string | string[] | - (required) |
| symbol | ReactNode | "$" |
| hideSymbol | boolean | false |
| copyValue | string | the lines, joined |
| hideCopyButton | boolean | false |
| onCopy | (text: string) => void | - |
| timeout | number (ms) | 2000 |
| isWrapped | boolean | false |
| variant | "outline" | "secondary" | "primary" | "outline" |
| size | "sm" | "md" | "lg" | "md" |
| copyLabel | string | "Copy" |
| copiedLabel | string | "Copied" |
| className | string | - |
SnippetTabs
| Prop | Type | Default |
|---|---|---|
| commands | Record<string, string | string[]> | - |
| children | SnippetTabList + SnippetTabPanel | - |
| defaultSelectedKey | string | the first tab |
| selectedKey | string | - |
| onSelectionChange | (key: string) => void | - |
| storageKey | string | - |
| variant | "outline" | "secondary" | "outline" |
| size | "sm" | "md" | "lg" | "md" |
| aria-label | string | "Commands" |
| className | string | - |
It also takes the settings of the snippet: symbol, hideSymbol, hideCopyButton, onCopy, timeout, isWrapped, copyLabel and copiedLabel, and passes them to every panel.
SnippetTabList, SnippetTab, SnippetTabPanel
| Part | Prop | Type |
|---|---|---|
| SnippetTabList | aria-label | string |
| SnippetTab | id | string (required) |
| SnippetTab | isDisabled | boolean |
| SnippetTabPanel | id | string (required) |
| SnippetTabPanel | children | string | string[] |
| SnippetTabPanel | copyValue | string |
| SnippetTabPanel | …the settings of the snippet | symbol, hideSymbol, isWrapped, … |
Command helpers
| Function | Returns | Options |
|---|---|---|
| installCommands(packages, options?) | bun add · npm install · yarn add · pnpm add | { dev?: boolean; global?: boolean } |
| executeCommands(command) | bunx · npx · yarn dlx · pnpm dlx | - |
| runCommands(script) | bun run · npm run · yarn · pnpm | - |