Kobana UI
GitHub

FilterBar

Barra de filtros reutilizável com múltiplos tipos de filtro.

Carregando...

Instalação

npx @kobana/ui add filter-bar

Dependências instaladas automaticamente: input, select, popover, calendar, button, badge (shadcn/ui)

Importação

import { FilterBar } from "@/components/kobana/filter-bar"

Props

PropTipoDefaultDescrição
filtersFilterConfig[]Configuração dos filtros
valuesRecord<string, unknown>Valores atuais dos filtros
onChange(values: Record<string, unknown>) => voidCallback de mudança
onClear() => voidLimpar todos os filtros
classNamestringClasses adicionais

FilterConfig

interface FilterConfig {
  key: string
  label: string
  type: "text" | "select" | "multi-select" | "date-range" | "custom"
  options?: { label: string; value: string }[]
  placeholder?: string
  component?: ReactNode  // para type="custom"
}

Tipos de Filtro

TipoComponenteDescrição
textInputCampo de busca textual
selectSelectSeleção única
multi-selectPopover + CheckboxesSeleção múltipla
date-rangeCalendarIntervalo de datas
customReactNodeComponente personalizado

Uso

<FilterBar
  filters={[
    { key: "search", label: "Buscar", type: "text", placeholder: "Nome ou ID..." },
    { key: "status", label: "Status", type: "select", options: [
      { label: "Ativo", value: "active" },
      { label: "Pendente", value: "pending" },
    ]},
    { key: "date", label: "Data", type: "date-range" },
  ]}
  values={filterValues}
  onChange={setFilterValues}
  onClear={() => setFilterValues({})}
/>

On this page