Menu
render Checkbox.new(size: :sm) render Checkbox.new(size: :md) render Checkbox.new(size: :lg)
Add the component to your project
Run the following command in your terminal
bundle exec essence add checkbox
Copy and paste the following code into your project
# frozen_string_literal: true
class Components::Checkbox < Components::Essence
BASE = "rounded-xs border border-gray-950/10 ring-gray-950/5 focus:outline-none focus:ring-offset-1 focus-visible:ring-1"
SIZES = {
sm: "size-3",
md: "",
lg: "size-5"
}
attr_reader :size
def initialize(size: :md, **attributes)
@size = size
super(**attributes)
end
def view_template
input(type: "checkbox", **attributes)
end
def initialize_merged_classes = merge_classes([ BASE, SIZES[size], attributes[:class] ])
end