x4js gallery
Every x4js component on its own page: live demos of its variations, a configurator of its props and the TypeScript code of each example.
For an assistant: llms.txt, llms-full.txt.
Add-ons
- Gantt: Tasks on a calendar: their list on the left, a tree of groups, their bars on the right, with milestones and arrows between them. The pointer moves a bar, stretches it, changes its progress; ctrl+wheel zooms. Not in x4js: it is imported from x4js/gantt.
- MapView: A map of tiles, openstreetmap by default, with markers and zones (polygons, circles, lines). It is moved with the pointer and zoomed with the wheel, its buttons, a double click or two fingers.
- MonacoEditor: The code editor of VS Code (Monaco) in a component: the languages, the completion, the themes of Monaco. Not in x4js: it is imported from x4js/monaco. Its files (14 MB) are copied by the application to its output, where the editor loads them; the gallery does not carry them, it loads them from jsDelivr.
- Planner: Events by day, week or month, as an agenda: the events with hours side by side in their day, the whole days in a band. The pointer creates, moves, stretches and copies them. Not in x4js: it is imported from x4js/planner.
Display components
- Bargraph: A level meter of segments, horizontal or vertical, drawn in a canvas: the accent or the colors given from min to max, an overshoot in the alert color, a peak that stays. Its value can change at each frame.
- Gauge: A dial and its needle, drawn in svg at the size of the component. The needle is moved by setPos: it has no prop.
- Icon: An icon: an inline svg, a data url, a CSS variable that holds an svg, an svg file loaded once and kept, or an image.
- Image: A picture: an <img> that fills the box of the component as fit says. It can also take a file the user drops on it.
- Label: A text with an icon before it. Its color is the variable --label-color, which the components that hold a label set.
- Link: A link (an <a>) with a text and an icon, or any content. Its click event comes before the browser follows it.
- Progress: A bar that shows where a value is between a min and a max: the progress of a work, a quota.
- Rating: A row of stars, the first ones lit: a score the user gives with a click, or shows.
- SimpleText: A text alone, without icon: lighter than a Label, it goes on several lines when it is too long.
- 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.
- Timeline: Events one after the other on a line, each with its icon in a round mark: a title, a sentence and its date, written relative to now. A done event has its mark in the accent colour; a click gives its item.
Extras
- Clipboard: The clipboard of the system: a text, an image, files. setClipboard and getClipboard from a button or a menu; in the copy, cut and paste events (Ctrl+C, Ctrl+V), setEventClipboard and getEventClipboard.
- DragDrop: dragManager makes a component something the user drags, and another one a place where it is dropped: components of the application, or files from the desktop.
- JSX: The components written as a tree, in a .tsx file: JSX only calls their constructors, there is no virtual DOM. In tsconfig.json: "jsx": "react" and "jsxFactory": "x4_react.create_element".
- Notification: A message in the bottom right corner of the window, for a few seconds or until it is closed; several pile up.
- PDF: X4PDFBuilder writes a PDF file in the browser, with no library: pages drawn in points, texts, lines, paths, svg icons, links and barcodes. build( ) gives its bytes, to show, download or send.
- State: makeState makes an object observable: its properties are read and written as usual, and on or watch is called at each change, with its path.
- Storage: The storage of the browser (localStorage), by the application: a string, a number or an object kept under a name, still there when the page is opened again. A component of yours keeps its state there with loadPState.
- SvgComponent: An <svg> element whose drawing is made with an SvgBuilder: shapes, paths, texts, gradients, groups, all in code.
- Theme: The colours of x4 are CSS variables: a theme only changes them. Application.setTheme gives the dark theme of x4, or one of the application (html.x4theme-<name>); a variable can also be written by the code.
- Tooltips: A text that shows under the pointer, on any component that has a tooltip. initTooltips( ) once at the start of the application turns them on.
Forms
- Form: A box that reads and writes together the fields it holds (those that have a name), and validates them.
- SettingsView: A page of settings, as the settings of VS Code: the summary of the sections on the left, the sections on the right, each SettingItem with its name, what it does and its controls.
Input components
- AutoComplete: A text field that asks for suggestions while the user types (the search event), from a list or a server. ↓ opens the list: the last suggestions, or a search of the text as it is, even empty.
- Checkbox: A box to check, with its label: a click on either changes it.
- ColorInput: A color field: a swatch and its text (rgb or hex), with a ColorPicker a click away.
- Combobox: A field and a dropdown list of items. The user picks an item; with readonly: false he can type to filter the list.
- FileDrop: A zone where files are dropped, or chosen with the file dialog of the system after a click. FileDialog is that dialog alone.
- Input: The native <input> field, of any type: text, password, number, date, time, checkbox, range, file. Without a label: see TextEdit for a field with one.
- Knob: A rotary button: a value on a range, on an arc of 270°, or a knob that turns without end. It is turned with the mouse, the wheel or the arrow keys.
- Radio: One choice among several: the radios with the same name are a group, a single one of them is checked.
- Select: The native select of the browser: one item, or several with multiple. Its value is the id of the item.
- Slider: A value between a minimum and a maximum, chosen by moving a thumb, with the mouse or the arrow keys.
- Switch: An on/off switch with its label: a checkbox drawn as a switch. In a Form, with a name, it is read and written as a boolean.
- TextArea: A text on several lines: TextArea, a label above a textarea, for a form; SimpleTextArea, the textarea alone. Their value is read with getText, written with setText.
- TextEdit: A label and an input on a line: the field of a form. It takes the props of an Input (text, email, password, number, date, time) and its label.
Layout containers
- AssistBox: A StackBox that goes from page to page in their order, without animation: for a wizard. For slides that move: Carousel.
- Carousel: Slides side by side that move, images or components: arrows, dots, a swipe with the finger or the mouse, the arrow keys and an autoplay. One slide seen at a time, or several.
- DockingView: Panels the user arranges by dragging their title: tools docked in bands on the sides (or floating), and the contents between them, split or as tabs.
- GridBox: A box that lays its children on a CSS grid: its rows and columns as a count or as tracks, each item in its cell, or named areas.
- HBox: A box that lays its children side by side, in a row: a flex box. Flex and Space set the room between them.
- MasonryBox: A box that lays its items in columns of 250px at least, as many as its width holds, each item as high as its content ("Pinterest").
- StackBox: A stack of pages where one only is shown at a time; a page given as a function is built the first time it is shown.
- VBox: A box that lays its children one under the other, in a column: a flex box. Its children take its width.
Lists / grids / trees
- Chart: A minimal svg chart: lines, areas, bars, pie, donut and radar, with axes, a legend and a click on the points. Its colors are CSS variables.
- Gridview: A grid of records: its rows come from a DataStore, its columns say which fields are shown and how. Only the rows in view are built, so it holds large stores.
- Listbox: A list of items to choose from: one or several, with icons, or drawn by a renderer of your own.
- PropertyGrid: Properties in two columns, their names and their editors, by groups: the editor follows the type of the property, and a callback gets each change.
- Spreadsheet: An editable grid of cells, backed by a Store (a value per row and column), with a header, a fixed column if needed, and inline editors.
- Treeview: A tree of items: the folders open and close, one item is selected at a time. An item is drawn from its text, its icon and its class.
Menus / button groups / tabs
- BtnGroup: A row (or a column) of buttons: predefined ones whose text follows the language, buttons of your own, spacers. btnclick gives the name of the one clicked.
- Button: A button with a text, an icon, or both. A click fires its click event, or opens its menu; it can repeat while held down.
- Menu: A popup list of commands: icons, titles, separators, sub-menus, checked items. It is built when it opens and closes when an item is clicked or the user clicks elsewhere.
- MenuBar: A row of titles at the top of a web application, each one opens its menu: the items of a Menu. A click opens it, the mouse on another title goes to its menu. A desktop application should use the menu of the system.
- Tabs: Pages one at a time, chosen by their tab. The content of a page can be built when it is shown the first time.
Popup / Dialog
- Dialog: A popup with a caption, a form and a bar of buttons; modal by default. showAsync gives the button clicked; show and btnclick let you decide when it closes.
- InputBox: Asks for one text in a modal box, with its static showAsync: the text after OK, null otherwise.
- MessageBox: A modal message with an icon and buttons, made by its static functions: showAsync waits for the button clicked, show does not.
- Popup: The base of what floats above the page: menus, dialogs, notifications. It is placed near a rectangle, at a point, or in the middle; it can close by itself on a click outside.
- ProgressionBox: A modal box that follows a long task: a title, a bar, the lines of what is done; it closes by itself when all went well.
- PromptBox: A modal box that shows a message and an editor of your own, with OK and Cancel; its static functions showAsync and show.
Sizers / viewport / misc
- Breadcrumbs: The path to the page shown, an element per level; a click on one gives its name, to go back to it.
- Calendar: A month to choose a day from, with the week numbers; the month and the year can be changed.
- Canvas: A <canvas> that paints itself with a callback, sharp on any screen: it is painted again when its size changes, or when redraw() is called.
- ColorPicker: A color chooser: a saturation square, a hue slider, an alpha slider and swatches. ColorInput opens one.
- Header: A row of column titles the user resizes. Each width is given to a CSS variable --<name>-width: a Listbox uses it for its columns, your own rows can too.
- HSplitBox: Panels side by side that the user resizes by dragging the line between them; VSplitBox stacks them. The sizers they put between their panels can also be placed by hand.
- Keyboard: A virtual keyboard for a touch screen: it shows itself at the bottom of its box while a field of the page has the focus.
- Panel: A frame with a title on its border (a legend), around a body that holds its content.
- ScrollView: A box that scrolls its viewport. It fills the box it is put in (absolute, 100%): that box gives its size.
- Section: A part of a page that folds: a title line (an icon, the title, a short summary, tools) and a body.
- TickLine: A tiny chart in svg, bars or a line, to show a trend in a cell or a status bar.
- Video: A <video> that plays a file (src) or shows a MediaStream: a camera, a screen, a canvas. play(), pause(), mute() and the player itself (player) drive it.