Join the Webstudio community

Updated 8 months ago

Token with custom CSS?

At a glance

The community member wants to add the .unselectable class to most elements on their site, which includes various vendor prefixes for the user-select property. However, they are unsure if this is the best approach, as some of the prefixes may not be supported. The comments suggest that the user-select property is widely supported without prefixes, and the community member can use it directly in the advanced section of their web platform. Another community member mentions that they can also use an HTML embed and a CSS selector to achieve the same result. The discussion also covers the automatic prefixing of the -webkit-user-select property to support Safari, which the community members agree is a good approach.

Useful resources
I would like to add the following class to the majority of elements on my site:
Plain Text
.unselectable {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

Of course it should be a token, but none of these are supported and likely won't be for a long time.
What would be the best way to add these? Surely using a HTML embed for a majority of elements can't be a good solution.
O
N
B
22 comments
Who in the world tought you you need to use all those prefixes, this is widely supported without a prefix

https://caniuse.com/?search=use-select
And already supported from advanced section
you can also do this with a html embed and a selector
Ah good point I've just been using this one for some years since they were all required, I can't seem to find user-select in the advanced menu, though:
Attachment
image.png
make a bigger screenshot
There is very little configuration so far as its a fresh project
now look exactly at your screenshot in advanced panel
Im going to cry
I assume in cases where something like this is actually unsupported, though, a javascript selector from an html embed is the only real way to go, though right?
I have no idea what you are talking about now
for example user-select doesn't work on webkit, it requires -webkit-user-select, which isn't supported. If I want to use that too, the best way would be with a javascript selector
I will just ignore that your sentence doesn't make any sense.

Here is what you are asking: in case there is a property we don't support in adnvanced panel but you still want to use - you can use html embed component and write any css there.

  1. It has nothing to do with javascript, its a css selector - which is why your sentence is confusing.
  2. user-select is supported, so there is no reason to write a prefix for it like I said before
Alright, I'm just figuring out how webstudio works in general and how regular css would be inserted
The user-select support on webkit, however, is a problem, though
On caniuse it confirms it
Attachment
image.png
we automatically add prefixed -webkit-user-select to support safari
Just checked - we automatically prefix
Alright perfect, thank you
In cases like this we should be prefixing automatically - if not - its basically a bug on our side.
Great I'll keep that in mind!
Add a reply
Sign up and join the conversation on Discord