Tag
A short text in a rounded frame, with an icon: a state, a keyword, a person. It has no method: its text and its icon are those of its props.
import { Tag } from "x4js"
Icons
A short text in a rounded frame, an icon before it.
export function icons( ) {
return new HBox( { cls: "tags", content: [
new Tag( { label: "Draft" } ),
new Tag( { label: "Done", icon: icon_check } ),
new Tag( { label: "Tomorrow", icon: icon_calendar } ),
new Tag( { label: "Alice", icon: icon_user } ),
] } );
}
.tags {
gap: 6px;
align-items: flex-start;
&.wrap {
flex-wrap: wrap;
}
}
Alert
The class alert gives a tag the colors of an alert.
export function alert( ) {
return new HBox( { cls: "tags", content: [
new Tag( { label: "Late", icon: icon_warning, cls: "alert" } ),
new Tag( { label: "3 errors", cls: "alert" } ),
] } );
}
Colors
A class of your own sets the CSS variables of the tag.
export function colors( ) {
return new HBox( { cls: "tags", content: [
new Tag( { label: "Paid", icon: icon_check, cls: "green" } ),
new Tag( { label: "Featured", icon: icon_star, cls: "outline" } ),
] } );
}
.x4tag.green {
--tag-background: var( --color-green-100 );
--tag-border: var( --color-green-600 );
--tag-color: var( --color-green-800 );
}
.x4tag.outline {
--tag-background: transparent;
--tag-border: var( --accent-background );
--tag-color: var( --accent-background );
}
A list
Tags made from an array, in a box that wraps them on several lines.
export function list( ) {
const keywords = [ "typescript", "components", "dom", "no virtual dom", "css variables", "router", "state", "forms", "dialogs", "grid" ];
return new HBox( { cls: "tags wrap", width: 360, content: keywords.map( k => new Tag( { label: k } ) ) } );
}
For an assistant: llms.txt, llms-full.txt.