Comments (8)
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.
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? 🤔
I can't send a specific link - but search for wrapper_class
on this page.
from crispy-tailwind.
from crispy-tailwind.
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.
See #61 for my first draft of what I was thinking...
from crispy-tailwind.
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.
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.
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)
- Passing required and disabled kwargs to ChoiceField not working HOT 2
- "selected"-Option is missing @SelectMultiple HOT 3
- Release for django 4.0 HOT 6
- Many to many field rendering
- Extra downward arrow in select widget HOT 3
- select elements don't include `id`
- [bug] checkboxmultipleselect is a radio HOT 2
- Duplicate arrows appearing outside of the dropwdown box. Arrows are large and very striking. HOT 8
- select_option.html inherits parent attributes HOT 1
- DAL Autocomplete not supported HOT 4
- CSS classes not found by tailwind watcher HOT 7
- Invite Ronny Vedrilla to team. HOT 28
- Automate versioning and releases HOT 3
- Add documentation for how to trigger release GitHub action
- DIV for select box not terminated HOT 3
- Run Linters in Pipeline / Actions HOT 8
- CI: Node 16 is deprecated
- Incorrect rendering of optgroups
- |crispy not compatible with Django's custom form.Select create_option() HOT 1
- Problems with django-smart-select
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crispy-tailwind.