Filter Chip
Filter Chip은 누를 때마다 필터 값을 켜고 끄는 작은 버튼입니다. 주로 검색 결과나 목록 위에 놓여 유형, 상태, 분야 같은 조건으로 결과를 좁힐 때 사용됩니다. 각 값 옆에 해당하는 결과 개수를 함께 보여 줄 수 있어 사용자가 필터를 고르기 전에 결과량을 가늠할 수 있습니다.
State
Code
vue
<script setup>
import { ref } from 'vue'
import { AFilterChip } from '@mobigen/rnd-design-system'
const selected = ref(['의료'])
const options = [
{ label: '의료', count: 42 },
{ label: '연구', count: 8 },
{ label: '건강검진', count: 0 }
]
function toggle(label) {
selected.value = selected.value.includes(label)
? selected.value.filter((v) => v !== label)
: [...selected.value, label]
}
</script>
<template>
<!-- 다중 선택 토글 -->
<AFilterChip
v-for="opt in options"
:key="opt.label"
:label="opt.label"
:count="opt.count"
:active="selected.includes(opt.label)"
:disabled="opt.count === 0 && !selected.includes(opt.label)"
@click="toggle(opt.label)"
/>
<!-- 상호배타 선택군 -->
<AFilterChip radio label="전체" :active="true" />
<AFilterChip radio label="1MB 미만" :active="false" />
</template>Props
| 속성 | 값 |
|---|---|
label | String (필수) |
count | Number |
active | true, false |
disabled | true, false |
radio | true, false |
Events
| 이벤트 | 전달 값 |
|---|---|
click | 없음 |
Notes
- 선택 상태를 내부에서 관리하지 않는다.
active와click을 호출부가 연결한다.