Live preview

Interactive example

Loading example…

Usage

Import the component and its manager, then make it your own.

ComponentIconInput
Managercreate_icon_input_manager

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>

API reference

Configure the manager, call its methods, and read its reactive state.

5 entries in configuration

PropertyTypeDefaultDescription
valany nullif is_icon_only is true, val is simply the icon key (string). otherwise val is an object { icon, color }
is_icon_onlyboolean falseif true, the value is just a string representing the icon key; color is ignored
icon_optionsarray a built-in list of sample icons if not providedarray of { key, name } objects describing available icons
on_finishfunction nullcallback triggered on 'finish'; receives the final val
is_button_compressedboolean truemakes the toggle button narrower if true