You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feature-request: enable input "free text" CSS value in every block attributes that accpet a CSS value #53595
Every time we can input a CSS value, for example for :
width
height
margin
color
background-color
...
We cannot input a valid CSS value if the UI doesn't support it yet.
It will be great to have a new custom option "free text" input that accepts any text, then the consumer is in charge to ensure that the value is a CSS valid value for that property.
I'm thinking this features for every attribute (that manage a CSS value) in every block.
The implementation of the UI control will be a simple <input type="text">.
Example - Spacer
Taking for example the Spacer block, looking at "Height" attribute, we can inject as value:
a spacing preset value of the scale defined in theme json
arbitrary value with NON-ARBITRARY "unit" (px, rem, vw, ....) but chosen from an available set of "unit"
as shown in image above
We cannot type other shapes.
We cannot type these value:
calc(100vh + 12px)
clamp(20px, 2vw, 40px)
Example - Image
In "Width" attribute we can't type "50%" for example, and in current design of the core library, we should wait that the core Image block will gain the percent unit in "width" input.
Which benefits this feature will add?
Dual benefits:
power user (web dev/web designer) has more familiar toolset
Wp core devs can ship less code (potentially)
In the current design of the core library, the core block author decides which unit a control support, so if the desired unit (from the consumer perspective) is not available he/she should wait that a "code" update of the block to add a specific unit to the input control.
Doing this kind of upgrade in every attribute, in every block is time-consuming, and we can "forget/postpone" this kind of update if we already have a fallback "free text" option.
I think that having a completely new "free text" option will ensure that the "power user" can gain flexibility while implementing a design and WP Core dev doesn't need to add a lot of UI code in React (in every block).
Future Vision
In a future, the "units" select (one that lets selecting px,rem, vw, ...), could be removed in favor of "free text" only.
This will simplify the code in React even more and leave full CSS spec for defining values to the user.
Useful Reference
Bricks builder started with a "select" like
and now is "free text only" like
Bricks builder is for dev/web designer that know the CSS spec.
But also "ch" unit is a thing that only a dev/web designer will know about.
So even if Wordpress Core Libary wants to be "abstract" and user friendly we already have some power user features like selecting "ch", "vh" and so on for some control.
So why not extend this ??
changed the title [-]feature-request: enable input "free text" value in every block attributes input[/-][+]feature-request: enable input "free text" CSS value in every block attributes that accpet a CSS value[/+]on Aug 11, 2023
It should support all default units or those set in the theme.json file, and it adds a new one called Custom where you can enter anything you like, like a calc() or variables. There is no validation except the one in the browser, which I'm fine with.
Activity
[-]feature-request: enable input "free text" value in every block attributes input[/-][+]feature-request: enable input "free text" CSS value in every block attributes that accpet a CSS value[/+]robizzt commentedon Dec 24, 2024
Here is my custom width control that can be used to extend core blocks:
WidthControl.js
And some styling to look like the default control:
custom-control-width.scss
It should support all default units or those set in the theme.json file, and it adds a new one called Custom where you can enter anything you like, like a calc() or variables. There is no validation except the one in the browser, which I'm fine with.