-
Notifications
You must be signed in to change notification settings - Fork 370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support different classes for different controls #2239
Comments
Hi @vanillajonathan, Thanks for the suggestion. This definitely makes sense to me. I'm wondering about the approach, whether we should split per property as suggested, i.e.
or split at the root level, i.e.
|
Hi, is there anything i can to do here? i can't see a problem here? You can already add classes via the uischemas options or customize everything directly via css selector. {
"type": "Control",
"scope": "#/properties/text",
"options": {
"styles": {
"control": {
"label": "label more classes",
"textarea": "text-area more classes",
"description": "description more classes"
}
}
} |
The |
@sdirix is changing the export interface Styles {
control: {
root?: string;
wrapper?: string;
input?: {
default?:string,
number?:string,
checkbox?:string,
}
textarea?: string;
select?: string;
}
} i mean, it breaks the whole an alternative could be: export interface Styles {
control: {
root?: string;
wrapper?: string;
input?: string;
inputNumber?: string;
inputCheckbox?: string;
textarea?: string;
select?: string;
}
} and at the renderer: <input
type="number"
:class="[styles.control.input, styles.control.inputNumber]"
... |
@davewwww All of the options are possible, we should just use the one which is most generic. @lucas-koehler and me discussed this. We think a root level split would be best, e.g. something like this
To avoid to redeclare the same properties for all splits, we could have a Does this fit your needs? |
Looks a bit overkill to me. i thought it was only about setting new classes at the input element based on its type? .wrapper:has(input:where([type="number"])) {
padding:1rem;
} i see a need for adding a type specific class at the input elements, but why on root, wrapper, description, error, eg. that it needs a root level split? This I would prefer a solution that keeps the "key.key=value" structure and adds another class to the input. <input type="number" class="control control-type-number" /> |
Hi @davewwww, Generally there are two different ways of styling the Vanilla renderers:
For writing custom CSS it's important that each rendered HTML element can be easily targeted. This is why we want to apply at least one class to all rendered elements. When using a CSS framework, the typical use case is to apply specific CSS classes to each rendered element. To support this use case JSON Forms needs to allow to apply arbitrary CSS classes to each element. The original request in this issue is tailored to the input use case and suggests allowing applying different classes to inputs. However thinking from a framework perspective, I would expect that there is a future feature request allowing to add different classes to the wrappers of these inputs too. Therefore our suggestion is to support this feature request generically and instead of only allowing to customize the classes of inputs, allow to customize the classes of all elements based on their type. This obviously solves the original request and allows other use cases too. The current styles are already nested one level. Besides backward compatibility I don't see the benefit of keeping it to one level. Note that there is actually some documentation. To make it a non breaking change we could use |
thanks for the explanation. so you mean something like that:
<input :class="[styles.control.input, styles?.['numberControl']?.input]" type="number" />
<input :class="styles?.['numberControl']?.input ?? styles.control.input" type="number" /> One more note: While working on my json forms editor, I need a JSON schema for the |
Is your feature request related to a problem? Please describe.
I cannot use the Bootstrap classes with the Vanilla renderer because the Vanilla renderer only lets you set one class for all
input
control types.In Bootstrap the inputs should have the
form-control
class but for checkboxes it should beform-check-input
instead.Describe the solution you'd like
A way to configure different CSS classes for different input types.
https://github.com/eclipsesource/jsonforms/blob/master/packages/vue-vanilla/src/styles/defaultStyles.ts
Perhaps:
could be:
Describe alternatives you've considered
Fork the Vanilla renderer.
Framework
Vue 3
RendererSet
Vanilla
Additional context
No response
The text was updated successfully, but these errors were encountered: