Progress Bar(ui_progress_bar)
UiBibz::Ui::Core::Notifications::ProgressBar
Examples for using Bootstrap custom progress bars featuring support for stacked bars, animated backgrounds, and text labels.
Usage
This component is an extension of component element. A Ui Bibz component consists of 3 arguments:
# by variable
ui_progress_bar content, options, html_options
# or by block
ui_progress_bar options, html_options do
content
end
# or by block with tap
ui_progress_bar options, html_options do |pb|
pb.bar content, options, html_options
# or
pb.bar options, html_options do
content
end
end
Examples
Some examples explain how to use the options present in the component.Progress Bar
ui_progress_bar 0
ui_progress_bar "25%", { status: :primary, value: 25 }, { class: "my-progress" }
ui_progress_bar({ status: :primary, value: 50 }, { class: "my-progress"}) do
50%
end
<div class="progress">
<div class="progress-bar" aria-valuenow="0.0" aria-valuemin="0" aria-valuemax="100" style="width: 0.0%" role="progressbar"></div>
</div>
<div class="my-progress progress">
<div class="bg-primary progress-bar" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100" style="width: 25%" role="progressbar"></div>
</div>
<div class="my-progress progress">
<div class="bg-primary progress-bar" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100" style="width: 50%" role="progressbar"></div></div>
</div>
status
ui_progress_bar 10, status: :primary
ui_progress_bar 25, status: :success
ui_progress_bar 50, status: :warning
ui_progress_bar 75, status: :danger
ui_progress_bar 100, status: :info
<div class="progress">
<div class="bg-primary progress-bar" aria-valuenow="10.0" aria-valuemin="0" aria-valuemax="100" style="width: 10.0%" role="progressbar"></div>
</div>
<div class="progress">
<div class="bg-success progress-bar" aria-valuenow="25.0" aria-valuemin="0" aria-valuemax="100" style="width: 25.0%" role="progressbar"></div>
</div>
<div class="progress">
<div class="bg-warning progress-bar" aria-valuenow="50.0" aria-valuemin="0" aria-valuemax="100" style="width: 50.0%" role="progressbar"></div>
</div>
<div class="progress">
<div class="bg-danger progress-bar" aria-valuenow="75.0" aria-valuemin="0" aria-valuemax="100" style="width: 75.0%" role="progressbar"></div>
</div>
<div class="progress">
<div class="bg-info progress-bar" aria-valuenow="100.0" aria-valuemin="0" aria-valuemax="100" style="width: 100.0%" role="progressbar"></div>
</div>
Line
ui_progress_bar 10, status: :primary, line: true
ui_progress_bar 25, status: :success, line: true
ui_progress_bar 50, status: :warning, line: true
ui_progress_bar 75, status: :danger, line: true
ui_progress_bar 100, status: :info, line: true
<div class="progress progress-bar-line">
<div class="bg-primary progress-bar" aria-valuenow="10.0" aria-valuemin="0" aria-valuemax="100" style="width: 10.0%" role="progressbar"></div>
</div>
<div class="progress progress-bar-line">
<div class="bg-success progress-bar" aria-valuenow="25.0" aria-valuemin="0" aria-valuemax="100" style="width: 25.0%" role="progressbar"></div>
</div>
<div class="progress progress-bar-line">
<div class="bg-warning progress-bar" aria-valuenow="50.0" aria-valuemin="0" aria-valuemax="100" style="width: 50.0%" role="progressbar"></div>
</div>
<div class="progress progress-bar-line">
<div class="bg-danger progress-bar" aria-valuenow="75.0" aria-valuemin="0" aria-valuemax="100" style="width: 75.0%" role="progressbar"></div>
</div>
<div class="progress progress-bar-line">
<div class="bg-info progress-bar" aria-valuenow="100.0" aria-valuemin="0" aria-valuemax="100" style="width: 100.0%" role="progressbar"></div>
</div>
Striped
ui_progress_bar 10, status: :primary, striped: true
ui_progress_bar 25, status: :success, striped: true
ui_progress_bar 50, status: :warning, striped: true
ui_progress_bar 75, status: :danger, striped: true
ui_progress_bar 100, status: :info, striped: true
<div class="progress">
<div class="bg-primary progress-bar progress-bar-striped" aria-valuenow="10.0" aria-valuemin="0" aria-valuemax="100" style="width: 10.0%" role="progressbar"></div>
</div>
<div class="progress">
<div class="bg-success progress-bar progress-bar-striped" aria-valuenow="25.0" aria-valuemin="0" aria-valuemax="100" style="width: 25.0%" role="progressbar"></div>
</div>
<div class="progress">
<div class="bg-warning progress-bar progress-bar-striped" aria-valuenow="50.0" aria-valuemin="0" aria-valuemax="100" style="width: 50.0%" role="progressbar"></div>
</div>
<div class="progress">
<div class="bg-danger progress-bar progress-bar-striped" aria-valuenow="75.0" aria-valuemin="0" aria-valuemax="100" style="width: 75.0%" role="progressbar"></div>
</div>
<div class="progress">
<div class="bg-info progress-bar progress-bar-striped" aria-valuenow="100.0" aria-valuemin="0" aria-valuemax="100" style="width: 100.0%" role="progressbar"></div>
</div>
Animated
ui_progress_bar 10, status: :primary, striped: true, animated: true
ui_progress_bar 25, status: :success, striped: true, animated: true
ui_progress_bar 50, status: :warning, striped: true, animated: true
ui_progress_bar 75, status: :danger, striped: true, animated: true
ui_progress_bar 100, status: :info, striped: true, animated: true
<div class="progress">
<div class="bg-primary progress-bar progress-bar-striped progress-bar-animated" aria-valuenow="10.0" aria-valuemin="0" aria-valuemax="100" style="width: 10.0%" role="progressbar"></div>
</div>
<div class="progress">
<div class="bg-success progress-bar progress-bar-striped progress-bar-animated" aria-valuenow="25.0" aria-valuemin="0" aria-valuemax="100" style="width: 25.0%" role="progressbar"></div>
</div>
<div class="progress">
<div class="bg-warning progress-bar progress-bar-striped progress-bar-animated" aria-valuenow="50.0" aria-valuemin="0" aria-valuemax="100" style="width: 50.0%" role="progressbar"></div>
</div>
<div class="progress">
<div class="bg-danger progress-bar progress-bar-striped progress-bar-animated" aria-valuenow="75.0" aria-valuemin="0" aria-valuemax="100" style="width: 75.0%" role="progressbar"></div>
</div>
<div class="progress">
<div class="bg-info progress-bar progress-bar-striped progress-bar-animated" aria-valuenow="100.0" aria-valuemin="0" aria-valuemax="100" style="width: 100.0%" role="progressbar"></div>
</div>
Stacked
ui_progress_bar 100, stacked: true, striped: true, animated: true
ui_progress_bar 100, stacked: true, inverse: true
ui_progress_bar 47, stacked: true
<div class="progress">
<div class="bg-success progress-bar progress-bar-striped progress-bar-animated" aria-valuenow="7.4" aria-valuemin="0" aria-valuemax="100" style="width: 7.4%" role="progressbar"></div>
<div class="bg-primary progress-bar progress-bar-striped progress-bar-animated" aria-valuenow="15.3" aria-valuemin="0" aria-valuemax="100" style="width: 15.3%" role="progressbar"></div>
<div class="bg-info progress-bar progress-bar-striped progress-bar-animated" aria-valuenow="21.1" aria-valuemin="0" aria-valuemax="100" style="width: 21.1%" role="progressbar"></div>
<div class="bg-warning progress-bar progress-bar-striped progress-bar-animated" aria-valuenow="25.9" aria-valuemin="0" aria-valuemax="100" style="width: 25.9%" role="progressbar"></div>
<div class="bg-danger progress-bar progress-bar-striped progress-bar-animated" aria-valuenow="30.3" aria-valuemin="0" aria-valuemax="100" style="width: 30.3%" role="progressbar"></div>
</div>
<div class="progress">
<div class="bg-danger progress-bar" aria-valuenow="7.4" aria-valuemin="0" aria-valuemax="100" style="width: 7.4%" role="progressbar"></div>
<div class="bg-warning progress-bar" aria-valuenow="15.3" aria-valuemin="0" aria-valuemax="100" style="width: 15.3%" role="progressbar"></div>
<div class="bg-info progress-bar" aria-valuenow="21.1" aria-valuemin="0" aria-valuemax="100" style="width: 21.1%" role="progressbar"></div>
<div class="bg-primary progress-bar" aria-valuenow="25.9" aria-valuemin="0" aria-valuemax="100" style="width: 25.9%" role="progressbar"></div>
<div class="bg-success progress-bar" aria-valuenow="30.3" aria-valuemin="0" aria-valuemax="100" style="width: 30.3%" role="progressbar"></div>
</div>
<div class="progress">
<div class="bg-success progress-bar" aria-valuenow="7.4" aria-valuemin="0" aria-valuemax="100" style="width: 7.4%" role="progressbar"></div>
<div class="bg-primary progress-bar" aria-valuenow="15.3" aria-valuemin="0" aria-valuemax="100" style="width: 15.3%" role="progressbar"></div>
<div class="bg-info progress-bar" aria-valuenow="21.1" aria-valuemin="0" aria-valuemax="100" style="width: 21.1%" role="progressbar"></div>
<div class="bg-warning progress-bar" aria-valuenow="12.173" aria-valuemin="0" aria-valuemax="100" style="width: 12.173%" role="progressbar"></div>
</div>
Progress bar with statuses
Status changes according to the percentage of progression.
[:success, :primary, :info, :warning, :danger]
You can pass our status array in statuses
option.
Percentage will be divided by the number of elements in statuses array.
ui_progress_bar 10, statuses: true
ui_progress_bar 34, statuses: true
ui_progress_bar 45, statuses: true
ui_progress_bar 62, statuses: true
ui_progress_bar 83, statuses: true
ui_progress_bar 49, statuses: [:primary, :danger]
<div class="progress"><div class="bg-success progress-bar" aria-valuenow="10.0" aria-valuemin="0" aria-valuemax="100" style="width: 10.0%" role="progressbar">10.0%</div></div>
<div class="progress"><div class="bg-primary progress-bar" aria-valuenow="34.0" aria-valuemin="0" aria-valuemax="100" style="width: 34.0%" role="progressbar">34.0%</div></div>
<div class="progress"><div class="bg-info progress-bar" aria-valuenow="45.0" aria-valuemin="0" aria-valuemax="100" style="width: 45.0%" role="progressbar">45.0%</div></div>
<div class="progress"><div class="bg-warning progress-bar" aria-valuenow="62.0" aria-valuemin="0" aria-valuemax="100" style="width: 62.0%" role="progressbar">62.0%</div></div>
<div class="progress"><div class="bg-danger progress-bar" aria-valuenow="83.0" aria-valuemin="0" aria-valuemax="100" style="width: 83.0%" role="progressbar">83.0%</div></div>
<div class="progress"><div class="bg-primary progress-bar" aria-valuenow="49.0" aria-valuemin="0" aria-valuemax="100" style="width: 49.0%" role="progressbar">49.0%</div></div>
Custom
ui_progress_bar do |pb|
pb.bar 25, status: :warning, striped: true
pb.bar 65, status: :danger
end
<div class="progress">
<div class="bg-warning progress-bar progress-bar-striped" aria-valuenow="25.0" aria-valuemin="0" aria-valuemax="100" style="width: 25.0%" role="progressbar"></div>
<div class="bg-danger progress-bar" aria-valuenow="65.0" aria-valuemin="0" aria-valuemax="100" style="width: 65.0%" role="progressbar"></div>
</div>