Created
October 24, 2022 18:35
-
-
Save LukasPol/d9fd5e9c5cc5fd8bcacc28c3e848c976 to your computer and use it in GitHub Desktop.
radio e checkbox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# simple form | |
config.wrappers :totem_radio_and_checkboxes, tag: :fieldset, class: '', :error_class => 'error' do |b| | |
b.use :html5 | |
b.use :label, class: 'font-medium text-lg mb-1' | |
b.wrapper :tag => 'div', :class => 'mt-1' do |ba| | |
ba.use :input, :class => 'input_radio_checkbox' | |
end | |
b.use :hint, wrap_with: { tag: :p } | |
b.use :error, wrap_with: { tag: :p, class: 'text-red-600' } | |
end | |
# css | |
.input_radio_checkbox:checked, | |
.input_radio_checkbox:not(:checked) { | |
position: absolute; | |
left: -9999px; | |
} | |
.input_radio_checkbox:checked + label, | |
.input_radio_checkbox:not(:checked) + label | |
{ | |
position: relative; | |
padding-left: 28px; | |
cursor: pointer; | |
line-height: 20px; | |
display: inline-block; | |
color: #666; | |
} | |
.input_radio_checkbox:checked + label:before, | |
.input_radio_checkbox:not(:checked) + label:before { | |
content: ''; | |
position: absolute; | |
left: 0; | |
top: 0; | |
width: 28px; | |
height: 28px; | |
border: 2px solid black; | |
border-radius: 100%; | |
background: #fff; | |
} | |
.input_radio_checkbox:checked + label:after, | |
.input_radio_checkbox:not(:checked) + label:after { | |
content: ''; | |
width: 14px; | |
height: 14px; | |
background: black; | |
position: absolute; | |
top: 7px; | |
left: 7px; | |
border-radius: 100%; | |
-webkit-transition: all 0.2s ease; | |
transition: all 0.2s ease; | |
} | |
.input_radio_checkbox:not(:checked) + label:after { | |
opacity: 0; | |
-webkit-transform: scale(0); | |
transform: scale(0); | |
} | |
.input_radio_checkbox:checked + label:after { | |
opacity: 1; | |
-webkit-transform: scale(1); | |
transform: scale(1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment