mix live_table.gen.live (live_table v0.4.0)
View SourceGenerates LiveView files with interactive data tables.
Creates the same files as phx.gen.live but replaces the basic table with an
interactive LiveTable component featuring sorting, searching, and filtering.
Usage
$ mix live_table.gen.live Context Schema table_name field:type field:type
Example
$ mix live_table.gen.live Accounts User users name:string email:string age:integer active:boolean
What You Get
Your index page will automatically include:
- Sortable columns - Click headers to sort by any field
- Search functionality - Search across text fields
- Smart filtering - Boolean toggles and numeric ranges
- Responsive design - Works on mobile and desktop
- Real-time updates - Live updates without page refresh
Field Behavior
Different field types get different capabilities:
- String fields → Searchable and sortable
- Text fields → Searchable (too long to sort effectively)
- Boolean fields → Filterable with true/false toggle
- Numeric fields → Filterable with min/max range sliders
- ID fields → Sortable only
Arguments
Same as phx.gen.live:
- Context: Business domain (e.g., Accounts, Blog)
- Schema: Data model (e.g., User, Post)
- table_name: Database table (e.g., users, posts)
- fields: Field definitions (e.g., name:string email:string)
Next Steps
After running this command:
- Run
mix ecto.migrateto create the database table - Start your server and visit the generated routes
- Customize field configurations and filters as needed