KKiotaPay UI
Browse documentation

Input

A labelled text input carrying its own label, required marker and error message. type="password" grows a reveal toggle on its own.

Installation

pnpm dlx shadcn@latest add https://kiotapay-ui-staging.staging.kiotapay.com/r/input.json

Installs components/custom/input.tsx and components/custom/form-field.tsx, the shared label and error chrome.

Usage

'use client'

import { Input } from '@/components/custom/input'

export function EmailField({ form }) {
  return (
    <Input
      label="Work email"
      type="email"
      required
      placeholder="ada@kiotapay.com"
      {...form.register('email')}
      error={Boolean(form.formState.errors.email)}
      errorMessage={form.formState.errors.email?.message}
    />
  )
}

Props

Extends React.ComponentProps<'input'>.

PropTypeDefaultDescription
labelstring—Required. Rendered above the field and wired to it by id.
mode'left' | 'center' | 'right''left'Aligns label, control and error together.
errorbooleanfalseSwitches the border and ring to the danger ramp.
errorMessageReactNode—Shown only while error is true.
requiredbooleanfalseAdds the asterisk and the required attribute.

Behaviour notes

Password fields are not a separate component. type="password" renders the eye toggle, so there is no call site that forgets to add one. The toggle is tabIndex={-1}: it is a convenience, and landing on it between the field and the submit button is a detour for anyone who never needed to see the value.

The asterisk is decorative. It carries aria-hidden, and the control's own required attribute is what assistive technology announces — otherwise the requirement is read out twice.

errorMessage is ignored unless error is set. That keeps a stale message from appearing after the field has been corrected but the copy not yet cleared.