Skip to content

FxIconSelect

Icon selector component with search, pagination, and multi-tab switching.

Starting from v1.0.7, UI presets are split into independent picker packages. The Vite plugin automatically detects installed picker packages and registers the FxIconSelect component.

Install Picker Package

Install the picker package for your UI framework:

bash
pnpm add @fuxishi/svg-icon-element-plus-picker
bash
pnpm add @fuxishi/svg-icon-naive-picker
bash
pnpm add @fuxishi/svg-icon-antdv-picker
bash
pnpm add @fuxishi/svg-icon-tdesign-picker
bash
pnpm add @fuxishi/svg-icon-vanilla-picker
UI FrameworkPicker PackageDependency
Element Plus@fuxishi/svg-icon-element-plus-pickerelement-plus
Naive UI@fuxishi/svg-icon-naive-pickernaive-ui
AntDv Next@fuxishi/svg-icon-antdv-pickerantdv-next
TDesign@fuxishi/svg-icon-tdesign-pickertdesign-vue-next
No UI Framework@fuxishi/svg-icon-vanilla-pickerNone

Usage

After installing a picker package, setupIcons(app) will automatically register the FxIconSelect component without any manual configuration:

ts
// main.ts
import { setupIcons } from 'virtual:fx-svg-icon'

const app = createApp(App)
setupIcons(app) // Auto-register FxIcon + detect picker package and register FxIconSelect

Use directly in templates:

vue
<template>
  <FxIconSelect v-model="iconName" placeholder="Select an icon" />
</template>

<script setup>
import { ref } from 'vue'
const iconName = ref('')
</script>

v1.0.6 and Earlier

WARNING

The following usage applies to v1.0.6 and earlier. For v1.0.7+, use the picker package approach above.

v1.0.6 and earlier, UI framework presets were built-in. FxIconSelect automatically detected the installed UI framework:

UI FrameworkDetection MethodPreset Component
Element PlusDetects ElPopover global componentElement Plus style selector
Naive UIDetects NPopover global componentNaive UI style selector
AntDv NextDetects APopover global componentAntDv Next style selector
TDesignDetects TPopup global componentTDesign style selector

After installing a UI framework, the selector automatically used the corresponding preset without extra configuration.

Props

PropTypeDefaultDescription
modelValuestringv-model bound icon name
placeholderstring'请选择图标'Placeholder text
heightnumber418Popover height (px)

Events

EventParametersDescription
update:modelValue(value: string)Emitted when an icon is selected

Headless Usage

If you don't use a UI framework preset, you can customize the selector UI via the useIconSelect composable:

vue
<template>
  <div>
    <input
      :value="iconSelect.inputValue.value"
      :placeholder="iconSelect.placeholder"
      readonly
      @click="iconSelect.handleInputClick"
    />
    <div v-if="iconSelect.visible.value">
      <!-- Custom selector UI -->
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useIconSelect } from '@fuxishi/svg-icon'

const iconName = ref('')
const iconSelect = useIconSelect({
  modelValue: () => iconName.value,
  onSelect: (value) => { iconName.value = value }
})
</script>

See useIconSelect for details.

View Custom Demo

Examples

Basic

vue
<template>
  <FxIconSelect v-model="iconName" />
  <p>Selected: {{ iconName }}</p>
</template>

Custom Height and Placeholder

vue
<template>
  <FxIconSelect
    v-model="iconName"
    placeholder="Click to select an icon"
    :height="500"
  />
</template>

CSS Variables

@fuxishi/svg-icon-vanilla-picker (Vanilla version) supports theme customization via CSS variables. Override them at the component's parent level:

css
/* Global override */
:root {
  --fx-primary: #1677ff;
  --fx-border-radius: 8px;
}

/* Or override for a specific selector */
.my-picker {
  --fx-primary: #1677ff;
}
vue
<template>
  <div class="my-picker">
    <FxIconSelect v-model="iconName" />
  </div>
</template>

Available Variables

VariableDefaultDescription
--fx-primary#409effPrimary color (selected, hover, active states)
--fx-primary-light#ecf5ffLight primary color (icon item hover background)
--fx-color-text-primary#303133Primary text color
--fx-color-text-regular#606266Regular text color
--fx-color-text-secondary#909399Secondary text color (icon names, hints)
--fx-color-text-placeholder#c0c4ccPlaceholder / disabled text color
--fx-color-bg#fffBackground color
--fx-color-bg-hover#f0f2f5Clear button hover background color
--fx-border-color#dcdfe6Border color
--fx-border-color-light#e4e7edLight border color (dividers, icon item borders)
--fx-border-radius4pxBase border radius
--fx-border-radius-lg6pxLarge border radius (input, popover)
--fx-font-size-sm12pxSmall font size
--fx-font-size-base13pxBase font size
--fx-font-size-md14pxMedium font size (input, tabs)
--fx-transition0.2sTransition duration