@@ -128,6 +128,64 @@ future_swatch_container.append(swatch);
128128 </script >
129129```
130130
131+ ### The ` label ` attribute
132+
133+ You can provide the color label via the ` label ` attribute.
134+
135+ <table >
136+ <thead >
137+ <tr>
138+ <th></th>
139+ <th>Default</th>
140+ <th>Large</th>
141+ </tr>
142+ </thead >
143+ <tbody >
144+ <tr >
145+ <th >Static</th >
146+ <td >
147+
148+ ``` html
149+ <color-swatch label =" Turquoise" >oklch(65% 0.15 210)</color-swatch >
150+ ```
151+ </td >
152+ <td >
153+
154+ ``` html
155+ <color-swatch label =" Turquoise" size =" large" >oklch(65% 0.15 210)</color-swatch >
156+ ```
157+ </td >
158+ </tr >
159+ <tr >
160+ <th >Editable</th >
161+ <td >
162+
163+ ``` html
164+ <color-swatch label =" Turquoise" >
165+ <input value =" oklch(65% 0.15 210)" />
166+ </color-swatch >
167+ ```
168+ </td >
169+ <td >
170+
171+ ``` html
172+ <color-swatch label =" Turquoise" size =" large" >
173+ <input value =" oklch(65% 0.15 210)" />
174+ </color-swatch >
175+ ```
176+ </td >
177+ </tr >
178+ </tbody >
179+ </table >
180+
181+ If the attribute's value matches the element's content, no additional text with the label will be shown.
182+
183+ ``` html
184+ <color-swatch label =" Turquoise" value =" oklch(65% 0.15 210)" size =" large" >Turquoise</color-swatch >
185+ ```
186+
187+ If used as a property and is not defined via the ` label ` attribute, its value is that of the element text content.
188+
131189### The ` info ` attribute
132190
133191You can use the ` info ` attribute to show information about the color.
@@ -256,6 +314,7 @@ If you don’t, the `<html>` element will be used.
256314| ` color ` | ` color ` | ` Color ` | ; ` string ` | - | The current color value. |
257315| ` info ` | ` info ` | ` string ` | - | Comma-separated list of coords of the current color to be shown. |
258316| ` value ` | ` value ` | ` string ` | - | The current value of the swatch. |
317+ | ` label ` | ` label ` | ` string ` | - | The label of the swatch (e.g., color name). Defaults to the element text content. |
259318| ` size ` | - | ` large ` | - | The size of the swatch. Currently, it is used only to make a large swatch. |
260319| ` property ` | ` property ` | ` string ` | - | CSS property to bind to. |
261320| ` scope ` | ` scope ` | ` string ` | ` :root ` | CSS selector to use as the scope for the specified CSS property. |
@@ -286,6 +345,7 @@ These properties are read-only.
286345| ------| -------------|
287346| ` swatch ` | The swatch used to render the color. |
288347| ` details ` | Wrapper around all non-swatch content (color name, info, etc) |
348+ | ` label ` | The label of the swatch |
289349| ` color-wrapper ` | Wrapper around the color name itself |
290350| ` gamut ` | Gamut indicator |
291351| ` info ` | Any info generateed by the ` info ` attribute |
0 commit comments