Ghostcn
Skip to Content
ComponentsPrimitives

Input

An accessible labeled native input, with optional hint and invalid/disabled states.

Install

npx ghostcn@1.4.0 add input --skip-existing

Usage

Place this field inside your own form. When supplying hint, provide a unique hintId for each instance. Use inputClass for the native control and class for the outer field.

{{> "components/input"
    label="Email address"
    type="email"
    name="email"
    hint="We will keep your email private."
    hintId="contact-email-hint"
}}

Component options

ParameterBehavior
variantVisual treatment; unknown values fall back to default. Values: default, filled. Default: default.
sizeComponent scale; unknown values fall back to default. Values: sm, default, lg. Default: default.
labelVisible accessible label. Default: Input.
typeNative input type. Values: text, email, search, url, number, password. Default: text.
nameForm field name.
valueInitial field value.
placeholderOptional placeholder (not a label).
hintOptional help text.
hintIdUnique ID for help text; provide with hint for aria-describedby.
invalidBoolean invalid state.
requiredBoolean required state.
disabledBoolean disabled state.

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

Customize this instance

{{> "components/input"
    label="Email address"
    type="email"
    name="email"
    hint="We will keep your email private."
    hintId="contact-email-hint"
    class="max-w-md" inputClass="rounded-xl border-purple-500"
}}

Styling parameters

ParameterTarget
classComponent root — .ghcn-ui-field
labelClass.ghcn-ui-field__label-text
inputClass.ghcn-ui-field__input
descriptionClass.ghcn-ui-field__hint

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

Installed files

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

View the registry source

Edit this page on GitHub

Was this helpful?

On this page