Sakani

Code Snippet

A code block with an optional filename header, copy button, and an editable mode.

npm install @sakaniui/react

No syntax highlighting

This renders plain monospaced text — it doesn't tokenise or colour code, and takes no language prop. That keeps a highlighter out of the bundle for the common case of showing an install command. For highlighted blocks, run the code through Shiki or Prism yourself (this docs site does exactly that in its own CodeBlock).

Filename and copy

The copy button lives in the header, so it only appears once filename is set.

example.tsx

import { Button } from '@sakaniui/react';

export function Example() {
  return <Button variant="primary">Get started</Button>;
}

Editable

playground.tsx

129 characters

Props

PropTypeDefaultDescription
codestringThe snippet body.
filenamestringSetting it shows the header row, which is also where the copy button lives.
onCopy(code: string) => voidFires after a successful copy, for analytics or a toast.
editablebooleanfalseLets people type into the block. Read-only otherwise.
onChange(code: string) => voidFires per keystroke. Only meaningful when editable.
placeholderstringShown when editable and empty.