# With clear button

> Clear button appears in the trailing addon when the field has text.

A shadcn/ui block from the [@flx](https://ui.flexnative.com) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/flx/input-07).

- Page, with a live preview: https://shadcn.exchange/r/flx/input-07
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/flx/input-07-light-123455ef760a5df5.png
- Registry item: https://ui.flexnative.com/r/input-07.json
- Listed: 2026-10-13, source last changed 2026-10-13

## Install

```bash
npx shadcn@latest add https://ui.flexnative.com/r/input-07.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- npm packages: `lucide-react`
- Registry items: `input-group`, `button`

## Files

### `registry/patterns/input/input-07.tsx`

```tsx
import { useState } from 'react'
import { XIcon } from 'lucide-react'

import {
  InputGroup,
  InputGroupAddon,
  InputGroupButton,
  InputGroupInput,
} from '@/components/ui/input-group'

export function Input07() {
  const [value, setValue] = useState('')

  return (
    <InputGroup className="max-w-sm">
      <InputGroupInput
        placeholder="Search..."
        value={value}
        onChange={(event) => setValue(event.target.value)}
      />
      {value.length > 0 && (
        <InputGroupAddon align="inline-end">
          <InputGroupButton
            aria-label="Clear"
            size="icon-xs"
            onClick={() => setValue('')}
          >
            <XIcon />
          </InputGroupButton>
        </InputGroupAddon>
      )}
    </InputGroup>
  )
}
```
