@@ -60,28 +60,28 @@ Or you can just import the compiled bundle at once:
60
60
import ' @umbraco-ui/uui-css/dist/uui-css.css' ;
61
61
```
62
62
63
- ### Applying the uui-css styling
63
+ ### Applying the uui-css styling in the root
64
64
65
65
Using the ` uui-font ` and ` uui-text `
66
66
67
67
``` html
68
- <div id = " app " class =" uui-font uui-text" >
69
- <h1 >Hello uui-css!</ h1 >
70
- < p >
71
- Everything inside my app will now use the font from uui-font and tag styling
72
- from uui-text because the app root has the uui- font and uui-text classes.
73
- </ p >
74
- < p style = " background : var ( --uui-interface-surface-alt ); " >
75
- I will have a background color from the custom properties.
76
- </p >
77
- </div >
68
+ <body class =" uui-font uui-text" >
69
+ <div id = " app " >
70
+ < h1 >Hello uui-css!</ h1 >
71
+ < p >
72
+ Everything inside my app will now use the font from uui-font and tag
73
+ styling from uui-text because the root(body) has the uui-font and uui-text
74
+ classes.
75
+ </ p >
76
+ </div >
77
+ </body >
78
78
```
79
79
80
- using the custom properties
80
+ Using the custom properties:
81
81
82
82
``` html
83
83
<p style =" background : var (--uui-interface-surface-alt );" >
84
- I will have a background color from the custom properties.
84
+ I will now have a background color from the custom properties.
85
85
</p >
86
86
```
87
87
@@ -95,13 +95,13 @@ Full example:
95
95
rel =" stylesheet"
96
96
href =" https://cdn.jsdelivr.net/npm/@umbraco-ui/uui-css@latest/dist/uui-css.css" />
97
97
</head >
98
- <body >
99
- <div id =" app" class = " uui-font uui-text " >
98
+ <body class = " uui-font uui-text " >
99
+ <div id =" app" >
100
100
<h1 >Hello uui-css!</h1 >
101
101
<p >
102
102
Everything inside my app will now use the font from uui-font and tag
103
- styling from uui-text because the app root has the uui-font and uui-text
104
- classes.
103
+ styling from uui-text because the root(body) has the uui-font and
104
+ uui-text classes.
105
105
</p >
106
106
<p style =" background : var (--uui-interface-surface-alt );" >
107
107
I will have a background color from the custom properties.
@@ -110,3 +110,60 @@ Full example:
110
110
</body >
111
111
</html >
112
112
```
113
+
114
+ ### Applying uui-text in a component
115
+
116
+ Import the text css from uui-css
117
+
118
+ ``` js
119
+ import { UUITextStyles } from ' @umbraco-ui/uui-css' ;
120
+ ```
121
+
122
+ Add the css to the component styles
123
+
124
+ ``` js
125
+ static styles = [
126
+ UUITextStyles,
127
+ css`
128
+ /* your css goes here */
129
+ ` ,
130
+ ];
131
+ ```
132
+
133
+ Add the ` uui-text ` class to the root of the component
134
+
135
+ ``` html
136
+ <div class =" uui-text" >This is my custom element</div >
137
+ ```
138
+
139
+ Full example:
140
+
141
+ ``` js
142
+ import { html , css , LitElement } from ' lit' ;
143
+ import { customElement } from ' lit/decorators.js' ;
144
+ import { UUITextStyles } from ' @umbraco-ui/uui-css' ;
145
+
146
+ @customElement (' my-element' )
147
+ export class MyElement extends LitElement {
148
+ static styles = [
149
+ UUITextStyles,
150
+ css`
151
+ /* your css goes here */
152
+ ` ,
153
+ ];
154
+
155
+ render () {
156
+ return html `
157
+ <div class =" uui-text" >
158
+ This is my custom element
159
+ </div >
160
+ ` ;
161
+ }
162
+ }
163
+
164
+ declare global {
165
+ interface HTMLElementTagNameMap {
166
+ ' my-element' : MyElement;
167
+ }
168
+ }
169
+ ```
0 commit comments