# Text field preview

Interactive preview of the CyberSpec Text field component. A labelled text input in a cut frame, with a hint, an error and an optional icon.

[View Text field preview on CyberSpec](https://www.cyberspec.dev/preview/text-field)

## About this preview

Text field belongs to the Fields group in the CyberSpec catalog. It uses @ui-sdk/react/input, @ui-sdk/react/field.

## Installation

Use a React 19 project with shadcn configured. Render the installed components inside the Cyber root, and import your global stylesheet in the app entry point.

```sh
bunx --bun shadcn@latest add https://www.cyberspec.dev/r/text-field.json
```

## Example

```tsx
"use client"

import { Radio } from "lucide-react"
import { TextField } from "@/components/ui/text-field"

export default function TextFieldDemo() {
  return (
    <>
      <TextField label="Handle" prefix="@" defaultValue="sable.quinn" hint="Shown to every crew you run with." autoComplete="off" clearable />
      <TextField
        label="Callsign"
        icon={<Radio />}
        defaultValue="STATIC-07"
        error="Callsign already registered in Lowtide."
        autoComplete="off"
        required
      />
      <TextField label="Relay node" defaultValue="NODE 3F:A2" disabled />
    </>
  )
}
```

## Install this example

```sh
bunx --bun shadcn@latest add https://www.cyberspec.dev/r/text-field-demo.json
```

## Resources

- [Text field documentation](https://www.cyberspec.dev/components/sidebar/text-field.md)
- [Component catalog](https://www.cyberspec.dev/components.md)
- [Text field source code](https://github.com/agnelnieves/cyberspec/blob/main/registry/cyber/ui/text-field.tsx)
- [Shadcn registry item](https://www.cyberspec.dev/r/text-field.json)
