includes()
functionsince 0.10experimentalrequires runtimeWhether a text contains another. Case-sensitive, compared in NFC form, without accent folding.
On this page · 8 sections+−
Syntax
includes(<text>, <part>)registry syntax: includes(text, part)
Parameters
- textstring or keywordrequired
- The text to search.
- partstring or keywordrequired
- What to find. An empty part is found.
Return value
A boolean.
Example
search.cssreactive
.list { --q: state(""); }.list input:on(input) { --q: set(lower(trim(event(value)))); }.card { --name: state(attr(data-name)); }.card:when(not includes(lower(--name), --q)) { display: none; }state()Function · hover any red tokenMakes each matching element the owner of an independent state with an initial value.Reference →
Behavior
- Combine with
lower()for a case-insensitive search. - 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
attr()in a condition is read when the condition's states change, not when only the attribute changes.
Related
Experimental · syntax may change between minor versions