Progress
Displays an indicator showing the completion progress of a task, typically displayed as a progress bar.
Example
Progress(value: 50, class: "w-[60%]")
Copied!
Copy failed!
With custom indicator color
Progress(value: 35, class: "w-[60%] [&>*]:bg-success")
Copied!
Copy failed!
Installation
Using RubyUI CLI
Run the install command
rails g ruby_ui:component Progress
Copied!
Copy failed!
Manual installation
1
Add RubyUI::Progress to app/components/ruby_ui/progress/progress.rb
# frozen_string_literal: true module RubyUI class Progress < Base def initialize(value: 0, **attrs) @value = value.to_f.clamp(0, 100) super(**attrs) end def view_template div(**attrs) do div(**indicator_attrs) end end private def default_attrs { role: "progressbar", aria_valuenow: @value, aria_valuemin: 0, aria_valuemax: 100, aria_valuetext: "#{@value}%", class: "relative h-2 overflow-hidden rounded-full bg-primary/20 [&>*]:bg-primary" } end def indicator_attrs { class: "h-full w-full flex-1", style: "transform: translateX(-#{100 - @value}%)" } end end end
Copied!
Copy failed!
2
Add RubyUI::ProgressDocs to app/components/ruby_ui/progress/progress_docs.rb
# frozen_string_literal: true class Views::Docs::Progress < Views::Base def view_template component = "Progress" div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do render Docs::Header.new(title: "Progress", description: "Displays an indicator showing the completion progress of a task, typically displayed as a progress bar.") render Docs::VisualCodeExample.new(title: "Example", context: self) do <<~RUBY Progress(value: 50, class: "w-[60%]") RUBY end render Docs::VisualCodeExample.new(title: "With custom indicator color", context: self) do <<~RUBY Progress(value: 35, class: "w-[60%] [&>*]:bg-success") RUBY end render Components::ComponentSetup::Tabs.new(component_name: component) render Docs::ComponentsTable.new(component_files(component)) end end end
Copied!
Copy failed!
Components
| Component | Built using | Source |
|---|---|---|
Progress | Phlex | |
ProgressDocs | Phlex |