Coder Social home page Coder Social logo

Comments (8)

sheckathorne avatar sheckathorne commented on August 20, 2024 2

For anyone else struggling with this issue, I ended up copying the field.html template to my project i.e. "templates > tailwind > field.html" and deleting the string instances of "mb-3" which has temporarily solved my problem. Would propose removing these mb-3 classes from the templates since there is no clear way to specify "field_class" when defining fields in Layout.

from crispy-tailwind.

smithdc1 avatar smithdc1 commented on August 20, 2024

Hi -- Thanks for the feedback. I'm super excited to have the first issue against this project!

With work and family commitments this week it may be a short while before I get to look at this deeply. In the meantime, just to check my gut reaction, does wrapper_class on the Field give you what you need here? 🤔

https://django-crispy-forms.readthedocs.io/en/latest/layouts.html?highlight=wrapper_class#universal-layout-objects

I can't send a specific link - but search for wrapper_class on this page.

from crispy-tailwind.

M2Industries avatar M2Industries commented on August 20, 2024

from crispy-tailwind.

smithdc1 avatar smithdc1 commented on August 20, 2024

Sorry. I focused too much on the comment about the mb-3.

I agree with your point about being able to customise the styles.

I have created a class CSSContainer to hold these customised classes which can be added to the helper. If it's not added the default styles are used.

Although I've not yet got round to documenting this and I'm not sure if this is the best approach and so would value your thoughts.

The benefit here is that the classes can be added once at the helper lever (via css_container). In the example you have had two write the classes out twice which is a bit verbose (and introduce risk of getting it wrong) especially with tailwind being a utility Framework.

https://www.github.com/django-crispy-forms/crispy-tailwind/tree/master/crispy_tailwind%2Ftailwind.py

from crispy-tailwind.

smithdc1 avatar smithdc1 commented on August 20, 2024

See #61 for my first draft of what I was thinking...

from crispy-tailwind.

M2Industries avatar M2Industries commented on August 20, 2024

what i did was simply remove the base_input styles and then add them in the helper. But yes! I think what you described is exactly what i was going for. Since tailwind is utility first I didnt mind not having base styles. It may deter users from using the form helper properly

If custom styles for a Field element are not supplied in the form helper then use the default "base_input" styles:

under CrispyTailwindFieldNode:
base_input = (
# "bg-white focus:outline-none border border-gray-300 rounded-lg py-2 px-4 block w-full "
# "appearance-none leading-normal text-gray-700"
""
)

from crispy-tailwind.

Nielssie avatar Nielssie commented on August 20, 2024

The benefit here is that the classes can be added once at the helper lever (via css_container).

Hello @smithdc1 Do you have an example how to do this. I can't figure it out. My goals is to give the checkboxselectmultiple a set of classes

from crispy-tailwind.

sheckathorne avatar sheckathorne commented on August 20, 2024

Hey guys, I read the discussion and read through the helpful docs in #61 , however overriding the default_styles still won't let me clear the mb-3 classes showing up in my form.

It looks like the templates are expecting a field_class attribute that I'm not sure how to set in my LayoutHelper:
<div class="{% if field_class %}{{ field_class }}{% else %}mb-3{% endif %}"{% if flat_attrs %} {{ flat_attrs|safe }}{% endif %}>

Any direction you can give is greatly appreciated!

-Sean

from crispy-tailwind.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.