Add `data-is-checked` to checkbox and radio wrappers.
See original GitHub issueDescribe the feature
Currently, I can’t add regular/static classes + conditional classes.
Simplified example:
<FormKit :wrapper-class="myVar && 'test-class'" wrapper-class="flex items-centercursor-pointer" type="radio"
:options="options">
</FormKit>
I know I can probably do something like :class="true && 'flex items-centercursor-pointer'; myVar && 'test-class'"
But this is kinda ugly.
I’m building a custom radio input, for which I want to add a border to the active/selected option
Issue Analytics
- State:
- Created 10 months ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Styling Radio Buttons with CSS (59 Custom Examples)
Radio buttons are website elements that allow a user to select one out of a series of options. They are very similar to...
Read more >Add a check box or option button (Form controls)
You can insert form controls such as check boxes or option buttons to make data entry easier. Check boxes work well for forms...
Read more >how to keep radio-button or checkbox and its label together ...
You can wrap the input and label in a <span> or wrap the input inside the label. Either way, the outer container (the...
Read more >Checkboxes, radio buttons, and menus - Contact Form 7
By default, a checkbox or a radio button are put first, and a label last. By adding label_first option, you can reverse them....
Read more >Pure CSS: Accessible Checkboxes and Radios Buttons
If you are reading this article, you know that adding custom styles to default checkboxes and radio buttons using just CSS is a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
There probably should be a simpler way. We’ll change this issue to reflect that instead. As for what is happening here — FormKit inputs are written (under “the hood”) using FormKit’s Schema — which means you can extend the schema object on a per-section basis. This is a really neat feature that gives you lots of power over the internals of each component that you normally would not have.
The
sections-schema
prop lets you target a given section with a chunk of schema that will be applied “on top” of the pre-existing one. So in the given exampledata-is-checked
is an attribute that is being added to theoption
section. It’s value is determined by the schema expression$fns.isChecked($option.value)
which basically just checks if that checkbox is checked or not.Thanks! Both solutions work.
However, I find this part quiet robust for simply adding a checked state:
Isn’t there a simpler way? And if not, can you please elaborate on what’s happening here? I can’t make it up from the docs