Date Picker Edit

Displays a calendar to pick a date — triggered by a button.

Examples

Installation


  rails generate shadcn-ui date-picker

Usage

<%= render_date_picker name: 'date', value:'2024-05-01' %>

The Dropdown Menu component introduces:

  • app/helpers/components/date_picker.rb
  • app/views/components/ui/_date_picker.html.erb
  • app/javascript/controllers/ui/date-picker_controller.js

The method render_date_picker defined in app/helpers/components/date_picker.rb accepts a block for the two inner components. Each of those accepts a block for their respective content.

Within the block, you can use the following methods:

  • - accepts an argument for the label section of the dropdown menu. This is optional.
  • - an arbitrary amount of these can be used for each menu item you want to include. This method either accepts a string or a block for the content you want.