Class targeting on shorthand input element: going ‘up’ as well as ‘down’ #2434
-
|
As mentioned in the docs, the The component also does double duty as a shorthand for a field group with an input field. If no The trouble is that if you apply classes to the shorthand component, they’re applied exclusively to the resulting, nested This means that, if for example you have a grid container and want to control the column span of a component, you must use the full, verbose syntax – a shorthand component with a label will always have no custom classes and therefore only have its inherited column span. To illustrate, take this Blade template: <div class="grid grid-cols-6">
<flux:input class="col-span-4" placeholder="Name" />
<flux:input class="col-span-2" label="Name" />
</div>That will render thus in the final HTML (very simplified, without Flux’ own classes and attributes): <div class="grid grid-cols-6">
<div class="col-span-4"> // spans 4 columns in grid container
<input type="text" placeholder="Name" />
</div>
<ui-field> // spans only 1 column in grid container
<ui-label>Name</ui-label>
<div class="col-span-2"> // not a grid element, so no colspan
<input type="text" />
</div>
</ui-field>
</div>It would be extremely useful to also add a |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
|
@kokoshneta thanks for the request! The <div class="grid grid-cols-6">
<flux:input class="col-span-4" placeholder="Name" />
<flux:input field:class="col-span-2" label="Name" />
</div>This follows the same Your comment did make us realise we needed to update the input component to support the |
Beta Was this translation helpful? Give feedback.
@kokoshneta thanks for the request! The
field:classattribute prefix actually already works for targeting the outermost<ui-field>element when using shorthand:This follows the same
nested:attributeconvention used by other components (e.g.,avatar:classon the profile component).Your comment did make us realise we needed to update the input component to support the
input:prefix to match this convention, so we've submitted a PR to add it as an alternative toclass:inputfor targeting the inner<input>element.