# IconInput — SvelteKit UI

Package: sveltekit-ui 1.1.94

Page: https://www.sveltekit-ui.com/components/icon_input

Category: Input controls

lets users pick an icon (and optionally its color), displaying a searchable list of available icons

Public component import: `IconInput`

Public manager import: `create_icon_input_manager`

## Usage

```svelte
<script>
  // Import the shared stylesheet once in your application's root layout.
  import "sveltekit-ui/style.css"
  import { IconInput, create_icon_input_manager } from "sveltekit-ui"

  const manager = create_icon_input_manager({
    is_icon_only: true,
    val: "star",
    icon_options: [
      { key: "star", name: "Star" },
      { key: "check", name: "Check" },
      { key: "heart", name: "Heart" },
    ],
  })
</script>

<IconInput {manager} />
<p>Selected icon: {manager.val}</p>
```

## Configuration

### `val`

- type: any
- default: null
- description: if is_icon_only is true, val is simply the icon key (string). otherwise val is an object { icon, color }

### `is_icon_only`

- type: boolean
- default: false
- description: if true, the value is just a string representing the icon key; color is ignored

### `icon_options`

- type: array
- default: a built-in list of sample icons if not provided
- description: array of { key, name } objects describing available icons

### `on_finish`

- type: function
- default: null
- description: callback triggered on 'finish'; receives the final val

### `is_button_compressed`

- type: boolean
- default: true
- description: makes the toggle button narrower if true

## Methods

### `init()`

- description: initializes state, managers for color input, searching, popover toggles, etc.
- parameters:
  - config: object
- returns: void

### `set_icon()`

- description: updates the chosen icon in val
- parameters:
  - input: string (the icon key)
- returns: void

### `set_is_icon_only()`

- description: toggles between is_icon_only: modifies val accordingly (string vs. { icon, color })
- parameters:
  - input: boolean
- returns: void

## Returned state

### `val`

- type: any
- description: the current selection. if is_icon_only is true, it's a string; otherwise an object { icon, color }

### `is_icon_only`

- type: boolean
- description: if true, val is just a string for the icon key

### `popover_manager`

- type: object
- description: popover manager controlling the icon picker popover

### `popover_toggle_button_manager`

- type: object
- description: button manager that opens/closes the icon picker popover

### `finish_button_manager`

- type: object
- description: button manager that finalizes and closes the picker, calling on_finish

### `icon_options_filtered`

- type: array
- description: the subset of icon options matching any search text

### `search_icons_text_input_manager`

- type: object
- description: manages the text input used to filter the icon list

### `color_input_manager`

- type: object
- description: manages color selection if is_icon_only is false

### `clear_button_manager`

- type: object
- description: button manager to reset val to null

### `icon_options`

- type: array
- description: the full array of possible icons

### `selected_icon_manager`

- type: object
- description: an icon manager instance for showing the currently selected icon
