Card Title
This is the card body
Protos is an open-source UI component library for Ruby. Browse 30+ accessible components built with Phlex, Tailwind CSS and DaisyUI.
Paragraph without a top margin
# frozen_string_literal: true
module Features
class Typography < ApplicationComponent
include Protos::Typography
# This will override h1-h4 + p and add inline_a
def view_template
ul(class: "flex flex-col gap-xs") do
li { h1(size: :xl) { "XL Hello, world!" } }
li { h2(size: :lg) { "LG Hello, world!" } }
li { h3(size: :md) { "MD Hello, world!" } }
li { h4(size: :sm) { "SM Hello, world!" } }
li { h4(size: :xs) { "XS Hello, world!" } }
li do
render Protos::Typography::Heading.new(level: 5, size: :sm) do
"H5 Hello, world!"
end
end
li do
render Protos::Typography::Heading.new(level: 6, size: :xs) do
"H6 Hello, world!"
end
end
li do
plain "This is some paragraph text "
inline_a(href: "https://example.com") { "with an inline link" }
end
li { p(margin: false) { "Paragraph without a top margin" } }
end
end
end
end
# frozen_string_literal: true
module Features
class Buttons < ApplicationComponent
COLORS = %i[default primary secondary accent info success warning error].freeze
VARIANTS = %i[default outline ghost link soft dash].freeze
SIZES = %i[default xs sm md lg xl].freeze
def view_template
div(class: "flex flex-col gap-sm") do
ul(class: "flex flex-wrap gap-sm") do
COLORS.each do |color|
li { button(color:) { color.to_s.capitalize } }
end
end
ul(class: "flex flex-wrap gap-sm") do
VARIANTS.each do |variant|
li { button(color: :primary, variant:) { variant.to_s.capitalize } }
end
end
ul(class: "flex flex-wrap items-center gap-sm") do
SIZES.each do |size|
li { button(color: :secondary, size:) { size.to_s.upcase } }
end
li { button(color: :success, active: true) { "Active" } }
li { button(disabled: true) { "Disabled" } }
end
ul(class: "flex flex-wrap items-center gap-sm") do
li { button(color: :primary, shape: :square) { icon("plus") } }
li { button(color: :error, shape: :circle) { icon("x-circle") } }
li do
button(element: :a, href: "#", color: :info, variant: :outline) do
"Link Button"
end
end
end
button(color: :primary, block: true) { "Block Button" }
button(color: :secondary, wide: true) { "Wide Button" }
end
end
private
def button(**, &)
render Protos::Button.new(**, &)
end
end
end
# frozen_string_literal: true
module Features
class Badges < ApplicationComponent
TYPES = %i[
default
primary
secondary
accent
info
success
warning
error
ghost
].freeze
SIZES = %i[default xs sm md lg xl].freeze
def view_template
div(class: "flex flex-col gap-sm") do
ul(class: "flex flex-wrap gap-sm") do
TYPES.each do |type|
li { badge(type:) { label(type) } }
end
end
ul(class: "flex flex-wrap gap-sm") do
li { badge(type: :primary, outline: true) { "Outline" } }
li { badge(type: :primary, dashed: true) { "Dashed" } }
li { badge(type: :primary, soft: true) { "Soft" } }
end
ul(class: "flex flex-wrap items-center gap-sm") do
SIZES.each do |size|
li { badge(type: :accent, size:) { size.to_s.upcase } }
end
end
end
end
private
def badge(type: :default, **, &)
render Protos::Badge.new(type:, **, &)
end
def label(type)
type == :default ? "Badge" : "#{type.to_s.capitalize} Badge"
end
end
end
# frozen_string_literal: true
module Features
class Statuses < ApplicationComponent
TYPES = %i[
default
primary
secondary
accent
info
success
warning
error
].freeze
SIZES = %i[default xs sm md lg xl].freeze
def view_template
div(class: "flex flex-col gap-sm") do
ul(class: "flex flex-wrap items-center gap-sm") do
TYPES.each do |type|
li { status(type:) }
end
end
ul(class: "flex flex-wrap items-center gap-sm") do
SIZES.each do |size|
li { status(type: :primary, size:) }
end
end
end
end
private
def status(type: :default, **, &)
render Protos::Status.new(type:, **, &)
end
end
end
# frozen_string_literal: true
module Features
class Comboboxes < ApplicationComponent
def view_template
render Protos::Combobox.new do |c|
c.trigger(id: "trigger", class: "btn btn-primary") do
"Select an option"
end
c.content do
c.list(class: "border rounded-box bg-base-300") do
c.input(placeholder: "Search...") { icon("magnifying-glass") }
c.empty { "No results found" }
c.group do
c.title { "Quick links" }
c.item { a(href: "#") { "Calendar" } }
c.item { a(href: "#") { "Projects" } }
end
end
end
end
end
end
end
# frozen_string_literal: true
module Features
class Commands < ApplicationComponent
def view_template
render Protos::Command.new do |c|
c.trigger(id: "trigger", class: "btn btn-primary") { "Open command" }
c.dialog do
c.list do
c.input(placeholder: "Search...") { icon("magnifying-glass") }
c.empty { "No results found" }
c.group do
c.title { "Suggestions" }
c.item { a(href: "#") { "Calendar" } }
c.item { a(href: "#") { "Search Emoji" } }
end
c.group do
c.title { "Settings" }
c.item { a(href: "#") { "Profile" } }
c.item { a(href: "#") { "Mail" } }
c.item { a(href: "#") { "Settings" } }
end
end
end
end
end
end
end
# frozen_string_literal: true
module Features
class Drawers < ApplicationComponent
def view_template
render Protos::Drawer.new(id: "some_id") do |c|
c.content do
c.trigger(id: "trigger", class: "btn btn-primary") { "Open Drawer" }
end
c.side(class: "z-[999]") do
ul(class: css[:menu]) do
li { a { "Main Menu" } }
end
end
end
end
private
def theme
{
menu: %w[
menu
p-4
w-80
min-h-full
bg-base-200
text-base-content
]
}
end
end
end
# frozen_string_literal: true
module Features
class Modals < ApplicationComponent
def view_template
div(class: "flex flex-wrap gap-sm") do
render Protos::Modal.new do |c|
c.trigger(id: "docs-modal-trigger", class: "btn btn-primary") do
"Open Modal"
end
c.dialog do
span { "This is the modal content." }
c.close_button(id: "docs-modal-close", class: "btn") { "Close" }
end
end
render Protos::Modal.new(close_on_backdrop_click: false) do |c|
c.trigger(id: "docs-form-modal-trigger", class: "btn btn-secondary") do
"Open Form Modal"
end
c.dialog do
form do
span { "This modal can only be closed with a button." }
c.close_button(class: "btn") { "Cancel" }
end
end
end
end
end
end
end


# frozen_string_literal: true
module Features
class Diffs < ApplicationComponent
def view_template
render Protos::Diff.new(class: "aspect-16/9 h-96") do |c|
c.item_one do
img(
src: asset_path("images/daisy-clear.webp"),
alt: "Daisy clear"
)
end
c.item_two(tabindex: 0) do
img(
src: asset_path("images/daisy-blur.webp"),
alt: "Daisy blurred"
)
end
c.resizer
end
end
end
end
# frozen_string_literal: true
module Features
class Dropdowns < ApplicationComponent
def view_template
div(class: "flex flex-wrap gap-sm") do
render Protos::Dropdown.new(position: :bottom, trigger: :click) do |c|
c.trigger(class: "btn btn-primary") { "Click dropdown" }
c.menu(class: "w-52 bg-base-300 rounded-box") do
c.item { a { "Item 1" } }
c.item { a { "Item 2" } }
end
end
render Protos::Dropdown.new(position: :right, trigger: :mouseenter) do |c|
c.trigger(class: "btn btn-secondary", as: :a, href: "#") do
"Hover dropdown link"
end
c.menu(class: "w-52 bg-base-300 rounded-box", as_template: false) do
c.item { a { "Item 1" } }
c.item { a { "Item 2" } }
end
end
end
end
end
end
# frozen_string_literal: true
module Features
class Accordions < ApplicationComponent
def view_template
div(class: "flex flex-col gap-sm w-full") do
render Protos::Accordion.new(
class: "border rounded-box",
input_name: "docs-accordion"
) do |c|
c.item do
c.title { "Accordion Item 1" }
c.content { "Accordion Item 1 Content" }
end
c.item do
c.title { "Accordion Item 2" }
c.content { "Accordion Item 2 Content" }
end
end
render Protos::Accordion.new(
class: "border rounded-box",
input_name: "docs-accordion-checkboxes",
input_type: :checkbox
) do |c|
c.item do
c.title { "Independent Item 1" }
c.content { "Multiple items can be open at once" }
end
c.item do
c.title { "Independent Item 2" }
c.content { "This item can also be opened" }
end
end
end
end
end
end
# frozen_string_literal: true
module Features
class Alerts < ApplicationComponent
COLORS = %i[default info success warning error].freeze
VARIANTS = %i[default outline dash soft].freeze
def view_template
div(class: "flex flex-col gap-sm w-full") do
COLORS.each do |color|
render Protos::Alert.new(color:) do |c|
c.icon { icon("check-circle") }
plain "#{color.to_s.capitalize} alert"
if color == :success
c.actions do
button(
class: "btn btn-sm btn-circle btn-ghost",
aria_label: "Dismiss"
) do
icon("x-circle", variant: :outline)
end
end
end
end
end
ul(class: "flex flex-wrap gap-sm") do
VARIANTS.each do |variant|
li do
render Protos::Alert.new(color: :info, variant:) do
plain "#{variant.to_s.capitalize} alert"
end
end
end
end
render Protos::Alert.new(color: :info, direction: :vertical) do |c|
c.icon { icon("check-circle") }
plain "Vertical alert"
c.actions do
button(class: "btn btn-sm") { "Action" }
end
end
end
end
end
end
# frozen_string_literal: true
module Features
class Avatars < ApplicationComponent
def view_template
div(class: "flex gap-sm items-center") do
with_placeholder
with_image(indicator: :online, shape: :circle)
with_image(indicator: :offline, shape: :squircle)
end
end
private
def with_image(indicator:, shape:)
render Protos::Avatar.new(
indicator:,
shape:,
theme: { figure: "bg-base-content text-neutral w-12" }
) do |c|
c.img(src: "https://i.pravatar.cc/300", alt: "NT")
end
end
def with_placeholder
render Protos::Avatar.new(
placeholder: true,
class: "text-base-100",
shape: :circle,
theme: { figure: "p-sm bg-base-content" }
) do |c|
c.plain("NT")
end
end
end
end
# frozen_string_literal: true
module Features
class ChatBubbles < ApplicationComponent
def view_template
ul(class: "space-y-md") do
li do
render Protos::ChatBubble.new do |c|
c.image { img(src: "https://i.pravatar.cc/300", alt: "Robert", class: "w-10 rounded-full") }
c.header { "Robert A. Caro" }
c.content { "Hey, how's it going?" }
c.footer { "12:45 PM" }
end
end
li do
render Protos::ChatBubble.new(align: :end) do |c|
c.header { "You" }
c.content(type: :primary) { "Pretty good, you?" }
c.footer { "12:46 PM" }
end
end
li do
render Protos::ChatBubble.new(align: :end) do |c|
c.content(type: :accent) { "See you tomorrow!" }
c.footer { "12:47 PM" }
end
end
end
end
end
end
# frozen_string_literal: true
module Features
class Collapses < ApplicationComponent
def view_template
div(class: "flex flex-col gap-sm w-full") do
render Protos::Collapse.new(
class: "border",
input_name: "docs-collapse",
icon: :plus
) do |c|
c.title { "Toggle" }
c.content { "This is the collapse content" }
end
render Protos::Collapse.new(
class: "border",
input_name: "docs-open-collapse",
input_type: :radio,
state: :open,
icon: :arrow
) do |c|
c.title { "Open by default" }
c.content { "This collapse starts expanded" }
end
end
end
end
end
# frozen_string_literal: true
module Features
class Lists < ApplicationComponent
def view_template
div(class: "flex flex-col gap-sm w-full") do
render Protos::List.new do |c|
c.item { "Item 1" }
c.item { "Item 2" }
c.item { "Item 3" }
end
render Protos::List.new(ordered: true, class: "bg-base-200 rounded-box") do |c|
c.item { "First item" }
c.item { "Second item" }
c.item { "Third item" }
end
render Protos::List.new(class: "bg-base-200 rounded-box") do |c|
c.item(wrap: true) { "Wrapped item content" }
c.item(grow: true) { "Growing item content" }
end
end
end
end
end
# frozen_string_literal: true
module Features
class Menus < ApplicationComponent
def view_template
div(class: "flex flex-wrap items-start gap-md") do
render Protos::Menu.new(class: "bg-base-200 rounded-box w-56") do |c|
c.item(title: true) { "Navigation" }
c.item { a(href: "#") { "Home" } }
c.item { a(href: "#") { "Projects" } }
c.item { a(href: "#") { "Settings" } }
end
render Protos::Menu.new(
direction: :horizontal,
size: :lg,
class: "bg-base-200 rounded-box"
) do |c|
c.item { a(href: "#") { "Overview" } }
c.item { a(href: "#") { "Activity" } }
c.item { a(href: "#") { "Members" } }
end
end
end
end
end
# frozen_string_literal: true
module Features
class Popovers < ApplicationComponent
def view_template
div(class: "flex flex-wrap gap-sm") do
render Protos::Popover.new(
position: :bottom,
animation: :scale,
trigger: :click
) do |c|
c.trigger(id: "docs-popover-trigger", class: "btn btn-primary") do
"Click popover"
end
c.content(theme: { container: "transition-all" }) do
ul(class: "menu border rounded-box") do
li { a(href: "#") { "Item 1" } }
li { a(href: "#") { "Item 2" } }
li { a(href: "#") { "Item 3" } }
end
end
end
render Protos::Popover.new(position: :right, trigger: :mouseenter) do |c|
c.trigger(
class: "btn btn-secondary",
as: :a,
href: "#",
id: "docs-hover-popover-trigger"
) do
"Hover popover link"
end
c.content(as_template: false) do
"This popover is positioned to the right."
end
end
end
end
end
end
| Name | Age | Status | Location |
|---|---|---|---|
| John Doe | 28 | Active | North Pole |
| Jane Smith | 33 | Active | South Pole |
| Total | 2 | Active |
# frozen_string_literal: true
module Features
class Tables < ApplicationComponent
def view_template
render Protos::Table.new(
size: :sm,
striped: true,
pin_rows: true,
pin_columns: true
) do |c|
c.caption(side: :top) { "Table Caption" }
c.header do
c.row do
c.head(align: :left) { "Name" }
c.head(align: :center) { "Age" }
c.head(align: :right) { "Status" }
c.head { "Location" }
end
end
c.body do
c.row do
c.cell { "John Doe" }
c.cell(align: :center) { "28" }
c.cell(align: :right) do
span(class: "badge badge-info") { "Active" }
end
c.cell { "North Pole" }
end
c.row do
c.cell { "Jane Smith" }
c.cell(align: :center) { "33" }
c.cell(align: :right) do
span(class: "badge badge-info") { "Active" }
end
c.cell { "South Pole" }
end
end
c.footer do
c.row do
c.cell { "Total" }
c.cell(align: :center) { "2" }
c.cell(align: :right) { "Active" }
c.cell { "" }
end
end
end
end
end
end
# frozen_string_literal: true
module Features
class Timelines < ApplicationComponent
EVENTS = [
["1984", "First Macintosh computer", false, true],
["1985", "First Windows computer", true, true],
["1998", "iMac", true, false]
].freeze
def view_template
div(class: "flex flex-col gap-md w-full") do
timeline
timeline(vertical: true)
end
end
private
def timeline(vertical: false)
render Protos::Timeline.new(vertical:) do |c|
EVENTS.each do |date, content, start, finish|
c.item do
hr(class: "bg-base-100") if start
c.left do
span(class: "badge badge-accent") { date }
end
c.center do
div(class: "w-6 h-6") { icon("check-circle") }
end
c.right(class: "timeline-box") do
span { content }
end
hr(class: "bg-base-100") if finish
end
end
end
end
end
end
# frozen_string_literal: true
module Features
class Breadcrumbs < ApplicationComponent
def view_template
render Protos::Breadcrumbs.new do |c|
c.crumb do
a(href: "#", class: "gap-2") do
icon("home", size: :sm)
span { "Home" }
end
end
c.crumb { a(href: "#") { "Accounts" } }
c.crumb { a(href: "#") { "Joe" } }
c.crumb { "Edit" }
end
end
end
end



# frozen_string_literal: true
module Features
class Carousels < ApplicationComponent
def view_template
div(class: "flex flex-col gap-md w-full") do
render Protos::Carousel.new(
class: "rounded-box h-96",
snap_to: :center
) do |c|
images.each_with_index do |image, index|
c.item { img(src: image, alt: "Example carousel image #{index + 1}") }
end
c.actions do
button(class: "btn btn-circle btn-sm", aria_label: "Previous") do
icon("chevron-left")
end
button(class: "btn btn-circle btn-sm", aria_label: "Next") do
icon("chevron-right")
end
end
end
render Protos::Carousel.new(
vertical: true,
class: "rounded-box h-92 w-auto mx-auto"
) do |c|
3.times do |index|
c.item(class: "h-full w-full") do
div(
class: %w[
w-full
grid
place-items-center
bg-base-200
p-lg
whitespace-nowrap
]
) do
"Slide #{index + 1}"
end
end
end
end
end
end
private
def images
[
asset_path("images/image-1.webp"),
asset_path("images/image-2.webp"),
asset_path("images/image-3.webp")
]
end
end
end
This is the card body
This is the card body
This is the card body
This is the card body
# frozen_string_literal: true
module Features
class Cards < ApplicationComponent
def view_template
div(class: "flex flex-wrap gap-md items-stretch justify-center") do
card(
border: true,
class: "bg-neutral text-neutral-content max-w-[300px]"
)
card(
image_side: true,
border: true,
class: "bg-base-100 max-w-[500px]",
image_class: "w-32"
)
card(
dashed: true,
border: true,
class: "bg-base-100 max-w-[300px]"
)
card(
image_full: true,
size: :sm,
class: "bg-neutral text-neutral-content max-w-[300px]"
)
end
end
private
def card(image_class: nil, **)
render Protos::Card.new(**) do |c|
c.image { img(src: image_url, alt: "Placeholder Image", class: image_class) }
c.body do
c.title { "Card Title" }
p { "This is the card body" }
c.actions do
button(class: "btn btn-primary btn-sm") { "Action" }
end
end
end
end
def image_url
"https://images.unsplash.com/photo-1709418359735-9cf3b793558d?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
end
end
end
# frozen_string_literal: true
module Features
class FloatingActionButtons < ApplicationComponent
def view_template
div(class: "flex flex-wrap items-center justify-center gap-xl") do
render Protos::FloatingActionButton.new(class: "relative") do |c|
c.open_button(class: "btn-primary btn-circle") { icon("plus") }
c.action(class: "btn btn-secondary btn-circle") { icon("pencil") }
c.action(class: "btn btn-error btn-circle") { icon("trash") }
end
render Protos::FloatingActionButton.new(
flower: true,
class: "relative"
) do |c|
c.open_button(class: "btn-primary btn-circle") { icon("plus") }
c.main_action(class: "btn btn-primary btn-circle") { icon("x-mark") }
c.action(class: "btn btn-secondary btn-circle") { icon("pencil") }
c.action(class: "btn btn-error btn-circle") { icon("trash") }
end
end
end
end
end
# frozen_string_literal: true
module Features
class Heroes < ApplicationComponent
include Protos::Typography
def view_template
render Protos::Hero.new(
class: "h-96 rounded-box w-full",
style: "background-image: url(#{asset_path("images/hero.webp")});"
) do |c|
c.overlay(class: "opacity-90")
c.content do
h2(size: :xl, class: "text-white") { "Hello, world!" }
end
end
end
end
end
# frozen_string_literal: true
module Features
class Stats < ApplicationComponent
def view_template
render Protos::Stats.new(class: "shadow") do |c|
c.stat do
c.title { "Total orders" }
c.value { "1,200" }
c.description { "21% more than last month" }
end
c.stat do
c.figure { icon("chart-bar") }
c.title { "Total sales" }
c.value { "$1,200" }
c.description { "Jan 1st - Feb 1st" }
c.actions do
button(class: "btn btn-xs") { "View report" }
end
end
c.stat do
c.title { "Avg. order value" }
c.value { "$1.00" }
end
end
end
end
end
# frozen_string_literal: true
module Features
class Steps < ApplicationComponent
def view_template
div(class: "flex flex-col gap-md w-full") do
render Protos::Steps.new do |c|
c.step(type: :primary) { "Register" }
c.step(type: :secondary) { "Choose plan" }
c.step(type: :accent) { "Purchase" }
c.step { "Complete" }
end
render Protos::Steps.new(vertical: true) do |c|
c.step(type: :success) { "Account created" }
c.step(type: :info) { "Profile completed" }
c.step { "Invite teammates" }
end
end
end
end
end
# frozen_string_literal: true
module Features
class Swaps < ApplicationComponent
def view_template
div(class: "flex flex-wrap items-center gap-md") do
render Protos::Swap.new(
class: "swap-lg",
input_options: { id: "docs-swap" }
) do |c|
c.on { icon("check-circle", size: :lg) }
c.off { icon("x-circle", size: :lg) }
end
render Protos::Swap.new(class: "swap-rotate") do |c|
c.on { icon("check", size: :lg) }
c.off { icon("x-mark", size: :lg) }
end
end
end
end
end
# frozen_string_literal: true
module Features
class Tabs < ApplicationComponent
VARIANTS = {
default: :md,
bordered: :md,
boxed: :lg,
lifted: :md
}.freeze
def view_template
div(class: "flex flex-col gap-sm") do
VARIANTS.each do |type, size|
render Protos::Tabs.new(type:, size:) do |c|
c.tab(active: true) { "Tab 1" }
c.tab { "Tab 2" }
c.tab { "Tab 3" }
c.tab(disabled: true) { "Disabled" }
end
end
end
end
private
def theme
{
item: %w[
rounded-box
border
p-sm
bg-base-100
]
}
end
end
end
# frozen_string_literal: true
module Features
class Toasts < ApplicationComponent
def view_template
render Protos::Toast.new(position: :top_center) do |toast|
render Protos::Alert.new(
color: :success,
class: "flex items-center flex-nowrap"
) do |alert|
plain("Hey, how's it going?")
alert.actions(class: "inline-flex") do
toast.close_button(id: "docs-toast-close") do
icon("x-circle", variant: :outline)
end
end
end
end
end
end
end