-
Notifications
You must be signed in to change notification settings - Fork 939
feat: add Filters component #5434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v4
Are you sure you want to change the base?
Conversation
commit: |
benjamincanac
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd strongly recommend opening up an issue to discuss things first before implementing all of this.
I don't think this belongs into Nuxt UI, the components you made are really specific and not extendable at all with hard-coded logic and styles.
I understand your concerns, but I'd like to clarify the design approach: On extensibility: On logic: Vision: This is my first contribution of this kind. I'm open to feedback and adjustments to align with Nuxt UI's standards. If it doesn't get merged, no worriesβit's been a great learning experience contributing to a project with such clean processes and structure. Either way, I hope it can inspire others or contribute to future discussions. PS : Not to worry, this component was made for a project of mine, I didn't take a lot of time porting this here. Because I wanted to see if it was useful first, I've added the component to the playground with some fake data and filtering logic if someone want's to play with it. |
π Linked issue
Resolves #5298
β Type of change
π Description
This PR introduces a complete new
Filterscomponent for Nuxt UI, inspired by Linear's filters UI. This component enables developers to create advanced and customizable filtering interfaces for data.Screenshot_2025-11-10-16.54.54.mp4
What was added:
Main component and sub-components:
Filters.vue- Main component that manages the display and manipulation of a list of active filtersFilterItem.vue- Represents an individual active filter with its field, operator, and value selectorAddFilterPopover.vue- Popover to add new filters with field searchFilterOperatorDropdown.vue- Dropdown to select a filter operatorFilterValueSelector.vue- Adaptive value selector based on field type and operatorFilterContextProvider.vue- Context provider to share configuration between all child componentsSelectOptionsPopover.vue- Popover to select options with search (uses CommandPalette)FilterDatePicker.vue- Single date selectionFilterDateRange.vue- Date range selectionFilterTimeRange.vue- Time range selectionFilterDateTimeRange.vue- Date/time range selectionFilterNumberRange.vue- Number range selectionTypeScript types:
src/runtime/types/filter.ts- Complete type definitions for the filter system:Utilities:
src/runtime/utils/operators.ts- Operator management by field type, default i18n configurationsrc/runtime/utils/fields.ts- Utilities to manipulate field configurations (flattening, search, grouping)src/runtime/utils/validation.ts- Validation functions for filter values (email, URL, tel, regex, custom)Composable:
src/runtime/composables/useFilterContext.ts- Composable to access the shared filter contextDocumentation:
docs/content/docs/2.components/filters.mdwith:Playground:
playgrounds/nuxt/app/pages/components/filters.vueWhy this change is required:
This component addresses the need to create complex and flexible filtering interfaces in Nuxt applications. It provides:
π Checklist
Known issues :
injectVue method for the context of the filtersAddFilterPopover.vueis needed for this to be fixedPS : I took this component from a project of mine, it does not follow NuxtUI's coding style (yet).
In conclusion, this component is far from perfect at this stage but I think it has the potential to be really useful for the community. We could add an integration with the Table component to make it work with TanStack filtering methods.
Thank you for your consideration β€οΈ