Skip to content

Search

This component is used for search scenarios, providing a combination of input box and search button, commonly used for search bars at the top of pages.

  • Supports round and square shapes
  • Supports displaying right action button (e.g., "Cancel")
  • Supports custom left and right slots
  • Supports one-click clearing of input content

Notice

This component may have slight differences in appearance across platforms. Please refer to the actual effect.

Platform Differences

App (vue)App (nvue)H5Mini Program

Basic Usage

  • Bind the search box value via v-model.
  • Set the placeholder text via placeholder, default is 'Search'.
html
<see-search v-model="value" />

<script lang="ts" setup>
import { ref } from 'vue';
const value = ref('');
</script>

Round/Square

  • Set the search box shape via shape. Available values are round (rounded corners) and square (square corners), default is round.
html
<see-search v-model="value" shape="round" />
<see-search v-model="value" shape="square" />

<script lang="ts" setup>
import { ref } from 'vue';
const value = ref('');
</script>

Action Button

  • Set isShowAction to true to display the right action button.
  • Set the action button text via actionText, default is 'Cancel'.
html
<see-search v-model="value" isShowAction />
<see-search v-model="value" isShowAction actionText="Search" />

<script lang="ts" setup>
import { ref } from 'vue';
const value = ref('');
</script>

Auto Focus

  • Set isFocus to true to make the search box automatically gain focus.
html
<see-search v-model="value" isFocus />

<script lang="ts" setup>
import { ref } from 'vue';
const value = ref('');
</script>

Clear Button

  • Set isClearable to true to display the clear button after input content, default is true.
  • Clicking the clear button will clear the input content and trigger the onClear event.
html
<see-search v-model="value" :isClearable="false" />

<script lang="ts" setup>
import { ref } from 'vue';
const value = ref('');
</script>

Custom Colors

  • Set the search box background color via bgColor.
  • Set isBorder to true to display the border.
html
<see-search v-model="value" bgColor="#f5f5f5" />
<see-search v-model="value" isBorder />

<script lang="ts" setup>
import { ref } from 'vue';
const value = ref('');
</script>

Custom Slots

  • Customize the left content of the search box via the left slot.
  • Customize the right content of the search box via the right slot.
html
<see-search v-model="value">
  <template #left>
    <text style="margin-right: 8px;">Category</text>
  </template>
  <template #right>
    <text style="margin-left: 8px;">Filter</text>
  </template>
</see-search>

<script lang="ts" setup>
import { ref } from 'vue';
const value = ref('');
</script>

Disabled State

  • Set isDisabled to true to disable the search box.
  • In disabled state, input events will not trigger.
html
<see-search v-model="value" isDisabled />

<script lang="ts" setup>
import { ref } from 'vue';
const value = ref('');
</script>

Readonly State

  • Set isReadonly to true to set the search box to readonly state.
  • In readonly state, content cannot be input, but click events can be triggered.
html
<see-search v-model="value" isReadonly />

<script lang="ts" setup>
import { ref } from 'vue';
const value = ref('');
</script>

Different Sizes

  • Set the search box size via the size parameter. Available values are small, default, and large.
html
<see-search v-model="value" size="small" />
<see-search v-model="value" size="default" />
<see-search v-model="value" size="large" />

<script lang="ts" setup>
import { ref } from 'vue';
const value = ref('');
</script>

API

Props

ParameterDescriptionTypeDefaultOptional ValuesPlatform Notes
modelValueBinding valuestring---
placeholderPlaceholder textstring'Search'--
isDisabledWhether disabledbooleanfalsetrue, false-
isReadonlyWhether readonlybooleanfalsetrue, false-
isClearableWhether to show clear buttonbooleantruetrue, false-
isShowActionWhether to show right action buttonbooleanfalsetrue, false-
actionTextAction button textstring'Cancel'--
isFocusWhether to auto focusbooleanfalsetrue, false-
shapeSearch box shape"round" | "square"'round'round, square-
sizeSize"small" | "default" | "large"'default'small, default, large-
isBorderWhether to show borderbooleanfalsetrue, false-
bgColorSearch box background colorstring-Any CSS color value-
nameForm field namestring''--

Events

Event NameDescriptionCallback Parameters
onInputTriggered when content is inputvalue: Current input value
onChangeTriggered when input content changes and is confirmedvalue: Current value
onFocusTriggered when input gains focusevent: Focus event object
onBlurTriggered when input loses focusevent: Focus event object
onClearTriggered when clear button is clicked-
onSearchTriggered when keyboard confirms searchvalue: Current input value
onCancelTriggered when action button is clicked-

Slots

Slot NameDescriptionParameters
leftCustom content on the left side of search box-
rightCustom content on the right side of search box-

Liao ICP No. 2025070134