length()
functionsince 0.10experimentalrequires runtimeThe number of characters a person sees: grapheme clusters, so an emoji with a skin tone is 1.
On this page · 8 sections+−
Syntax
length(<text>)registry syntax: length(text)
Parameters
- textstring or keywordrequired
- Numbers, booleans and datetimes are an error, never converted.
Return value
A number.
Example
counter.cssreactive
.form { --value: state(""); }.form textarea:on(input) { --value: set(event(value)); }.form .count { text: length(trim(--value)); }state()Function · hover any red tokenMakes each matching element the owner of an independent state with an initial value.Reference →
Behavior
- Uses
Intl.Segmenter. It differs from the HTMLmaxlengthattribute, which counts UTF-16 code units. - In the arguments,
--namereads a state;var(--name)works too.
Supported contexts
:on()actions:set(lower(event(value))).:when()andwhen()conditions::when(includes(--a, --b)).- Declarations, including
text::text: length(trim(--value)).
Limitations
Related
Experimental · syntax may change between minor versions