Skip to content

ComponentsFormatting

SourceSource

Inline Code

A monospace pill for code inside a line of message text.

A monospace pill for code inside a line of message text. Compose it from the exported registry parts so local content and behaviour stay in the application while the visual contract stays token-driven.

Root class newt-inline-code
import { InlineCode } from "@/registry/bases/newt/ui/inline-code"

export default function InlineCodeDemo() {
  return (
    <p className="text-sm text-newt-text-secondary">
      Run <InlineCode>pnpm install</InlineCode> to get started.
    </p>
  )
}
<script setup lang="ts">
import { InlineCode } from "~~/registry/bases/newt/ui/inline-code"
</script>

<template>
  <p class="text-sm text-newt-text-secondary">
    Run <InlineCode>pnpm install</InlineCode> to get started.
  </p>
</template>

Installation

npx newtui@latest add inline-codenpx shadcn@latest add @newtui/inline-codenpx shadcn-vue@latest add @newtui/inline-codepnpm dlx newtui@latest add inline-codepnpm dlx shadcn@latest add @newtui/inline-codepnpm dlx shadcn-vue@latest add @newtui/inline-codeyarn dlx newtui@latest add inline-codeyarn dlx shadcn@latest add @newtui/inline-codeyarn dlx shadcn-vue@latest add @newtui/inline-codebunx newtui@latest add inline-codebunx shadcn@latest add @newtui/inline-codebunx shadcn-vue@latest add @newtui/inline-codedeno run -A npm:newtui@latest add inline-codedeno run -A npm:shadcn@latest add @newtui/inline-codedeno run -A npm:shadcn-vue@latest add @newtui/inline-codevlx newtui@latest add inline-codevlx shadcn@latest add @newtui/inline-codevlx shadcn-vue@latest add @newtui/inline-codevp dlx newtui@latest add inline-codevp dlx shadcn@latest add @newtui/inline-codevp dlx shadcn-vue@latest add @newtui/inline-codenubx newtui@latest add inline-codenubx shadcn@latest add @newtui/inline-codenubx shadcn-vue@latest add @newtui/inline-codenlx newtui@latest add inline-codenlx shadcn@latest add @newtui/inline-codenlx shadcn-vue@latest add @newtui/inline-codeupx newtui@latest add inline-codeupx shadcn@latest add @newtui/inline-codeupx shadcn-vue@latest add @newtui/inline-code

The shadcn CLI needs the @newtui registry in your components.json. Set it up.

Copy the source into your project

import * as React from "react"

import { cn } from "@/lib/utils"

const InlineCode = React.forwardRef<HTMLElement, React.ComponentProps<"code">>(
  ({ className, ...props }, ref) => (
    <code
      ref={ref}
      className={cn(
        /* `pre-wrap` keeps wrapped code readable without eating the spacing. */
        "whitespace-pre-wrap rounded-[var(--newt-radius-sm)] border border-newt-border bg-newt-bg-base px-1 font-[family-name:var(--newt-font-mono)] text-[0.85em] text-newt-text-primary",
        className
      )}
      {...props}
    />
  )
)
InlineCode.displayName = "InlineCode"

export { InlineCode }
<script setup lang="ts">
import type { HTMLAttributes } from "vue"

import { cn } from "@/lib/utils"

const props = defineProps<{ class?: HTMLAttributes["class"] }>()
</script>

<template>
  <!-- `pre-wrap` keeps wrapped code readable without eating the spacing. -->
  <code
    :class="
      cn(
        'whitespace-pre-wrap rounded-[var(--newt-radius-sm)] border border-newt-border bg-newt-bg-base px-1 font-[family-name:var(--newt-font-mono)] text-[0.85em] text-newt-text-primary',
        props.class
      )
    "
  >
    <slot />
  </code>
</template>
export { default as InlineCode } from "./InlineCode.vue"

Update the import paths

The files import @/lib/utils and sibling components through the aliases in your components.json. Point them at wherever those live in your project.

No CLI, no components.json: paste this into Claude, Cursor, Copilot or any coding assistant and it adds Inline Code to your React project by hand. The prompt carries the source of every file the CLI would write — this component's and those of the components it builds on — with the imports already pointed at the default aliases.

No CLI, no components.json: paste this into Claude, Cursor, Copilot or any coding assistant and it adds Inline Code to your Vue project by hand. The prompt carries the source of every file the CLI would write — this component's and those of the components it builds on — with the imports already pointed at the default aliases.

Usage

import { InlineCode } from "@/components/ui/inline-code"

export function Example() {
  return <InlineCode />
}
<script setup lang="ts">
import { InlineCode } from "@/components/ui/inline-code"
</script>

<template>
  <InlineCode />
</template>

API reference

InlineCode

PropType
children / default slot?React.ReactNode / Vue slot

Content rendered inside the component.

TypeReact.ReactNode / Vue slot
className / class?string

Additional classes merged with the component defaults.

Typestring

The registry exports InlineCode. Parts without a table accept the native attributes for the element they render; React uses className, while Vue uses class and fallthrough attributes.

Accessibility

Preserve the native semantics of the rendered elements and pass through ARIA attributes when the surrounding context needs a label or description. Any interactive child needs a visible focus indicator, and meaning must not rely on colour alone.

Tokens

Inline Code reads its colours, radii and motion from the --newt-* tokens installed with the library. Override a token and every component that reads it follows, including this one — see the token layer. In the plain HTML and CSS distribution the same component is newt-inline-code.

  • --newt-border
  • --newt-radius-sm
  • --newt-bg-base
  • --newt-text-primary
  • --newt-font-mono