<div id="div_id_remember" class="field-wrapper mb-3">
<label for="id_remember" class="inline-flex relative items-center cursor-pointer">
<input type="checkbox"
id="id_remember"
name="remember"
class="sr-only peer"
>
<div class="w-11 h-6 bg-gray-200 rounded-full dark:bg-gray-700 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[ dark:peer-focus:ring-blue-800''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"></div>
<span class="ml-3 text-sm font-medium text-gray-900 select-none dark:text-gray-300">Remember me</span>
</label>
</div>
def toggle_switch(self, **kwargs):
class TestForm(forms.Form):
remember = forms.BooleanField(
widget=HammerToggleSwitchWidget,
required=False,
label="Remember me",
)
form = TestForm()
template = Template(
"""
{% load formify %}
{% render_field form.remember %}
""",
)
return template.render(Context({"form": form}))