docs
Docs
C++ API
C API
Search API
Ctrl K
2.0
2.0
latest
1.4
Ultralight C++ API
2.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
CSSPropertyName.h
Go to the documentation of this file.
1
///
2
/// Copyright (C) 2026 Ultralight, Inc. All rights reserved.
3
/// A license is required for commercial use. https://ultralig.ht
4
///
5
#pragma once
6
#include <Ultralight/dom/detail/StyleNames.h>
7
8
namespace
ultralight
{
9
namespace
dom
{
10
11
///
12
/// A CSS property name checked when your code compiles (the type of dom::css).
13
///
14
/// An unknown name is a compile error. You'd normally write one as dom::css.
15
///
16
template
<detail::FixedString Name>
17
struct
CSSPropertyName
{
18
static_assert
(detail::IsKnownCSSProperty(detail::kCSSName<Name>),
19
"unknown CSS property name; check the spelling (custom properties start "
20
"with --)"
);
21
22
///
23
/// Get the property's CSS name (null-terminated). A camelCase name comes back in CSS form
24
/// (eg, `background-color` for `backgroundColor`).
25
///
26
static
constexpr
const
char
*
name
() {
return
detail::kCSSName<Name>.data(); }
27
};
28
29
///
30
/// A CSS property name checked when your code compiles.
31
///
32
/// Use it where style access takes a property name, so a typo is a compile error instead of a
33
/// write that silently does nothing:
34
///
35
/// ```
36
/// el.style[dom::css<"background-color">] = "purple";
37
/// el.style[dom::css<"backgroundColor">] = "purple"; // the same property
38
/// el.style[dom::css<"--accent">] = "#ff3366";
39
/// std::string size = dom::getComputedStyle(el)[dom::css<"font-size">];
40
/// ```
41
///
42
/// Write a name in lowercase CSS form (`background-color`) or in the camelCase form JavaScript
43
/// uses for it (`backgroundColor`, `cssFloat` for `float`). Prefixed legacy names (eg,
44
/// `-webkit-border-radius` or `webkitBorderRadius`) work too, and any custom property name (`--`
45
/// followed by at least one character) is accepted.
46
///
47
/// @note For a name you only know at run time, pass a string instead (eg,
48
/// `el.style["background-color"]`). An unknown name then does nothing.
49
///
50
template
<detail::FixedString Name>
51
inline
constexpr
CSSPropertyName<Name>
css
{};
52
53
}
// namespace dom
54
}
// namespace ultralight
ultralight::dom
Direct C++ access to modify page elements and handle events.
ultralight::dom::css
constexpr CSSPropertyName< Name > css
A CSS property name checked when your code compiles.
Definition
CSSPropertyName.h:51
ultralight
Root namespace for every public Ultralight type, function, and enumeration.
ultralight::dom::CSSPropertyName
A CSS property name checked when your code compiles (the type of dom::css).
Definition
CSSPropertyName.h:17
ultralight::dom::CSSPropertyName::name
static constexpr const char * name()
Get the property's CSS name (null-terminated).
Definition
CSSPropertyName.h:26
Ultralight
dom
CSSPropertyName.h
Docs
C++ API
C API
Version
2.0
2.0
latest
1.4