Filter Edit

Displays a list that is filterable via the included input.

Examples

Ruby on Rails
Next.js
Remix.run

Installation


  rails generate shadcn-ui filter

Usage

<%= render_filter items do %>
  <%# Optional  %>
  <%= filter_icon do %>
  <% end %>
<% end >

The Filter component introduces:

  • app/helpers/components/filter_helper.rb
  • app/views/components/ui/_filter.html.erb
  • app/javascript/controllers/ui/filter_controller.js

The method render_filter method accepts one mandtory argument, an array of hashes that each have a value and name name.

You can optionally also call filter_icon within a block passed to render_filter to render an icon to the left of the filter input.

This component gets used in the Combobox and Command components as well as potentially others.

Ruby on Rails
Next.js
Remix.run