Required asterisk for form elements #1155
Replies: 2 comments 1 reply
-
Some googled examples of the standard asterisk that people are used to see: I mean, you could pick how you want it to look. Doesn't even have to be red or an asterisk as long as it gets the point across. I just want a dedicated, simple way to highlight a form field as required. Add a class to it, and people can re-style if they're not happy with the default look, or they can skip using the required attribute and create their own. Small thing, but flux is in the details :) |
Beta Was this translation helpful? Give feedback.
-
An option if you want to implement your own style: Add this to your [data-flux-label].required {
@apply after:content-['*'] after:ml-0.5 after:text-red-500;
} Run Then setup like so: <form wire:submit="search">
<flux:field>
{{-- Note the class="required" here... --}}
<flux:label class="required">Domain</flux:label>
<div class="flex items-center justify-start gap-2">
<flux:input
wire:model="domain"
placeholder="domain.com"
icon="magnifying-glass"
autofocus
clearable
/>
<flux:button variant="primary" type="submit">
{{ __('app.buttons.search') }}
</flux:button>
</div>
<flux:error name="domain" />
</flux:field>
</form> |
Beta Was this translation helpful? Give feedback.
-
It would be great to be able to just add "required" or something like "required-label" to a flux form element to display a required asterisk next to the label.
I've found badge, but it's a little clumsy to restyle and seems like a hijack.
Beta Was this translation helpful? Give feedback.
All reactions