Skip to content

[css-forms-1] Add UA style rules for text fields #11897

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lukewarlow
Copy link
Member

@lukewarlow lukewarlow commented Mar 10, 2025

No description provided.

```css
input:is([type=text], [type=search], [type=email], [type=password], [type=tel], [type=url], [type=number]),
textarea {
display: inline-grid;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should maybe use the modern syntax?


```css
input:not([type]),
input:is([type=text], [type=search], [type=email], [type=password], [type=tel], [type=url], [type=number]),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is every textual input?

color: color-mix(in srgb, currentColor 50%, transparent);
display: none;
line-break: anywhere;
grid-area: 1/1;
Copy link
Member Author

@lukewarlow lukewarlow Mar 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used to stack the elements atop each other. Not aware of a way to do this using flex?

}

::placeholder {
color: color-mix(in srgb, currentColor 50%, transparent);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly too low contrast (same would apply to disabled button-like text)

::field-text {
grid-area: 1/1;
/* Should be cursor width but that's not exposed */
min-width: 1px;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what to do about this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would maybe need adjusting based on this (e.g. using calc-size) #12019 (comment)

@lukewarlow
Copy link
Member Author

cc @mfreed7 due to your comments around flex layout.

textarea {
display: inline-grid;
padding-inline: 2px;
field-sizing: content;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we maybe also want to set cursor to text for these?

input:is([type=text], [type=search], [type=email], [type=password], [type=tel], [type=url], [type=number]),
textarea {
display: inline-grid;
padding-inline: 2px;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be 0.125em? (2/16)

input:is([type=text], [type=search], [type=email], [type=password], [type=tel], [type=url], [type=number]) {
overflow-x: auto;
scrollbar-width: none;
padding-block: 1px;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be 0.0625em? (1/16)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally padding should be consistent across select, buttons and inputs


textarea {
overflow-y: auto;
padding-block: 2px;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@lukewarlow lukewarlow marked this pull request as draft April 30, 2025 16:14
@lukewarlow lukewarlow marked this pull request as ready for review July 16, 2025 22:29
@lukewarlow
Copy link
Member Author

@nt1m do you have any thoughts on this? Currently we have nothing defined for these so it would be good to make some progress on it but we don't have a strong definition for placeholder or field-text yet?

@nt1m
Copy link
Member

nt1m commented Jul 16, 2025

@nt1m do you have any thoughts on this? Currently we have nothing defined for these so it would be good to make some progress on it but we don't have a strong definition for placeholder or field-text yet?

They seem reasonable, but also hard to verify without prototyping

@lukewarlow
Copy link
Member Author

https://codepen.io/lukewarlow/pen/wBvqovL - here's a custom element with the applied styles that should demonstrate roughly what it looks like.


::field-text {
grid-area: 1/1;
min-block-size: 1lh;
Copy link
Member Author

@lukewarlow lukewarlow Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably needs a font-size: max(1em, 24px) rule

grid-area: 1/1;
min-block-size: 1lh;
/* Should be cursor width but that's not exposed */
min-inline-size: 1px;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this actually be 24px? So the textarea/input is never smaller than 24px x 24px?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this really belongs on field-text, ditto for min-block-size/font-size. Ideally they'd just inherit what they need from the parent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants