Searchbar
Searchbar (검색 상자)
검색바 컴포넌트예요. 검색어를 입력받고, 지우기 버튼과 좌우 아이콘 슬롯을 제공해서 검색 화면의 기본 구성 요소로 쓰기 좋아요.
출처: 문서
본문
소개 (Intro)
검색바예요.
설치 (Install)
import { createApp } from 'vue'
import { Searchbar } from '@nutui/nutui'
const app = createApp()
app.use(Searchbar)
데모 (Demos)
아래 항목들은 원문 문서의 대화형 데모로 제공돼요.
- 기본 사용법 (Basic Usage) —
demo: searchbar basic - 모양 (Shape) —
demo: searchbar shape - 왼쪽 슬롯 (Left Slot) —
demo: searchbar left - 오른쪽 슬롯 (Right Slot) —
demo: searchbar right - 배경 (Background) —
demo: searchbar background - 포커스 스타일 (Focus Style) —
demo: searchbar focus - 지우기 아이콘 (Clear Icon) —
demo: searchbar clear - 모든 슬롯 (All Slots) —
demo: searchbar all
API
Props
| Parameter | Description | Type | Default |
|---|---|---|---|
| v-model | current input value | number / | string |
| label | left text of search box | string | '' |
| shape | search box shape, optional value is square round |
string | round |
| max-length | maximum input length | number | string | 9999 |
| input-type | input box type | string | text |
| placeholder | The default dark pattern of the input box | string | Please enter |
| clearable | whether to show clear button | boolean | true |
| clear-icon | custom clear button icon (default use @nutui/nutui-icons) |
Object | CircleClose |
| background | external background of the input box | string | #fff |
| input-background | background of input box | string | #f7f7f7 |
| autofocus | Whether to automatically focus | boolean | false |
| focus-style | search box style when focused | Object | - |
| disabled | Whether to disable the input box | boolean | false |
| readonly | input field is read only | boolean | false |
| input-align | alignment, optional left center right |
string | left |
safe-area-inset-bottomv4.1.6 |
Whether to enable the security zone at the bottom of the full screen of iphone series | boolean | false |
Events
| Event Name | Description | Callback Parameters |
|---|---|---|
| change | fires when something is entered | val, event |
| focus | fires on focus | val, event |
| blur | Triggered when out of focus | val, event |
| clear | Triggered when click clear | val |
| search | fires when the ENTER key is pressed | val, event |
| click-input | Fired when the input field is clicked | event |
| click-left-icon | Fires when the left icon is clicked | val, event |
| click-right-icon | Fires when the right icon is clicked | val, event |
Slots
| Name | Description |
|---|---|
| leftin | left icon in the input box |
| leftout | left Icon outside the input box |
| rightin | right icon in the input box |
| rightout | right icon outside the input box |
Theming
CSS Variables
The component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.
| Name | Default Value |
|---|---|
| --nut-searchbar-background | var(--nut-white) |
| --nut-searchbar-right-out-color | var(--nut-black) |
| --nut-searchbar-padding | 9px 16px |
| --nut-searchbar-width | 100% |
| --nut-searchbar-input-background | #f7f7f7 |
| --nut-searchbar-input-padding | 0 0 0 13px |
| --nut-searchbar-input-height | 32px |
| --nut-searchbar-input-width | 100% |
| --nut-searchbar-input-border-radius | 16px |
| --nut-searchbar-input-box-shadow | 0 0 8px 0 rgba(0, 0, 0, 0.04) |
| --nut-searchbar-input-bar-color | inherit |
| --nut-searchbar-input-bar-placeholder-color | inherit |
더 알아보기 (Learn more)
- 원문 문서: Searchbar — NutUI v4 영문 문서
- NutUI 저장소: jd-opensource/nutui