# style in modal (form)

**URL:** <https://forum.djangoproject.com/t/style-in-modal-form/19186>\
**Category:** Templates & Frontend\
**Created:** [March 1, 2023, 12:42pm UTC](https://forum.djangoproject.com/t/style-in-modal-form/19186 "2023-03-01T12:42:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![peya02](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/peya02/32/11900_2.png) [@peya02](https://forum.djangoproject.com/u/peya02)\
**Post date:** [March 1, 2023, 12:42pm UTC](https://forum.djangoproject.com/t/style-in-modal-form/19186/1 "2023-03-01T12:42:16Z")

</div>

Can someone help me with information about styles in a form?

I have a form which I open through a modal, the problem is that I want to create a certain style.

This is what I get now:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/3/378cd7dd7ccf530c2322272346bdc0144c88c841.png)

For example, I would like the Reason section (it is a CheckboxSelectMultiple) to appear ordered and without overlapping with everything.

thank you

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [March 1, 2023, 1:36pm UTC](https://forum.djangoproject.com/t/style-in-modal-form/19186/2 "2023-03-01T13:36:07Z")

</div>

You style a form pretty much the same way you style anything else. Typically, you assign the appropriate css classes to the form elements, with those css classes defined in a `.css` file.

How this is done depends upon how you’re rendering your form fields. If you’re rendering the fields manually, you can specify classes in the [`attrs`](https://docs.djangoproject.com/en/4.1/ref/forms/widgets/) argument to the widget. If you’re using a Crispy layout, you specify the [`css_class`](https://django-crispy-forms.readthedocs.io/en/latest/layouts.html#layout-objects-attributes) on the element.

For us to provide more specific details, we’d need to see the form and how you’re rendering it. (For example, specifying attributes for a widget in a ModelForm is slightly different than how you would do it on a regular form.)

---

<div class="post-metadata">

**Author:** ![peya02](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/peya02/32/11900_2.png) [@peya02](https://forum.djangoproject.com/u/peya02)\
**Post date:** [March 1, 2023, 1:48pm UTC](https://forum.djangoproject.com/t/style-in-modal-form/19186/3 "2023-03-01T13:48:34Z")

</div>

I am using a modal and in the forms.py file I have something like this:

```auto
widgets = {
            'num_reclamacion': forms.TextInput(
                attrs = {
                    'class': 'form-control',
                    'placeholder': 'Nº reclamacion',
                }
            ),
            'motivo': forms.RadioSelect(
                attrs = {
                    'placeholder': 'Motivo reclamacion',
                }
            ),

```

My modal:

```auto
<div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">
        <div class="modal-header">
            <h2 class="modal-title">Creacion de Reclamación</h2>
            <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
            </button>
        </div>
        <form id="form_creacion" action="{% url 'registrar_reclamacion' %}" method="POST">
            {% csrf_token %}
            <div class="modal-body">
                <div id="errores">

                </div>
                {{ form.as_p }}
            </div>
            <div class="modal-footer">
                <button class="btn btn-danger" type="button" onclick="cerrar_modal_creacion();">Cancelar</button>
                <button id="boton_creacion" class="btn btn-primary" type="button" onclick="registrar();">Confirmar</button>
            </div>
        </form>
    </div>
</div>

```

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [March 1, 2023, 1:52pm UTC](https://forum.djangoproject.com/t/style-in-modal-form/19186/4 "2023-03-01T13:52:50Z")

</div>

You may end up needing to specify widgets in your `widgets` dict for all the fields you need to add classes to.

Whether you have css classes already available to you depends upon whether you’re using a css framework such as tailwind or bootstrap, or if you need to create your own css classes.

---

<div class="post-metadata">

**Author:** ![peya02](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/peya02/32/11900_2.png) [@peya02](https://forum.djangoproject.com/u/peya02)\
**Post date:** [March 2, 2023, 6:20am UTC](https://forum.djangoproject.com/t/style-in-modal-form/19186/5 "2023-03-02T06:20:51Z")

</div>

I’m using bootstrap and the style seems fine to me, the problem is that I don’t know how to put, for example, two fields in the same row, or three… mostly structure it as I want but following the style it has.

---

<div class="post-metadata">

**Author:** ![peya02](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/peya02/32/11900_2.png) [@peya02](https://forum.djangoproject.com/u/peya02)\
**Post date:** [March 2, 2023, 8:59am UTC](https://forum.djangoproject.com/t/style-in-modal-form/19186/6 "2023-03-02T08:59:35Z")

</div>

Well I already found a way where I can create more of the style. Thank you so much.
