Ghostcn
Skip to Content
ComponentsPrimitives

Button

A native button or link with variants, sizes and per-instance classes.

Install

npx ghostcn@1.4.0 add button --skip-existing

Usage

Omit href for a native button; it defaults to type="button". Use trusted URLs for links. A disabled link has no href or Portal action. Use class on the button itself; there is no buttonClass slot.

{{> "components/button" text="About the publication" href="/about/" variant="outline"}}

Component options

ParameterBehavior
variantVisual treatment; unknown values fall back to default. Values: default, secondary, outline, ghost, destructive, link. Default: default.
sizeComponent scale; unknown values fall back to default. Values: sm, default, lg. Default: default.
textVisible, escaped label. Default: Button.
hrefTrusted link URL. Omit to render a button.
typeButton type (ignored for links). Values: button, submit, reset. Default: button.
disabledBoolean. Disables a button or removes navigation from a link.
ariaLabelOptional accessible name.
dataPortalOptional native Ghost Portal action for enabled links.

Use unquoted booleans, for example true and false, rather than strings.

Customize this instance

{{> "components/button" text="About the publication" href="/about/" variant="outline" class="rounded-xl bg-purple-700 text-white hover:bg-purple-800"}}

Styling parameters

ParameterTarget
classComponent root — .ghcn-ui-button

Styling parameters affect only elements that render. See Style component instances for specificity, dark mode, and preserving customizations.

Installed files

  • partials/components/button.hbs
  • assets/css/components/button.css

View the registry source

Edit this page on GitHub

Was this helpful?

On this page