### Media Query Example Source: https://github.com/blushister/tesseraui/wiki/Changelog Apply styles based on screen width. ```CSS @media (min-width / max-width) { ... } ``` -------------------------------- ### Use Loaded Components Source: https://github.com/blushister/tesseraui/wiki/Component-System Example of using the 'card' and 'badge-row' components after their file has been loaded. ```html

Title

New Hot
``` -------------------------------- ### Recommended Development Setup with Rebuild Source: https://github.com/blushister/tesseraui/wiki/Hot-Reload Rebuild the screen on init to ensure it reloads correctly, especially after pressing F3+T. This includes invalidating the cache and rebuilding the template. ```java @Override protected void init() { // Always rebuild on init so pressing F3+T re-loads the screen too rebuild(); } private void rebuild() { TesseraHotReload.invalidateAll(); // call only in dev builds root = TesseraTemplateRenderer.build( TesseraTemplate.load("yourmod:ui/my_screen"), model, handlers, px, py, pw, ph ); } ``` -------------------------------- ### TesseraPalette Example Usage Source: https://github.com/blushister/tesseraui/wiki/Color-and-Palette Illustrates how to use constants from TesseraPalette to style UI components like panels and labels, ensuring a consistent design. ```java TesseraPanel card = TesseraPanel.column(x, y, w, h) .background(TesseraPalette.BG2) .border(1, TesseraPalette.COPPER_LO) .padding(6).gap(4); card.add(new TesseraLabel(0, 0, w - 12, 10, "Title") .color(TesseraPalette.COPPER_HI) .fontSize(8f)); card.add(new TesseraLabel(0, 0, w - 12, 9, "Description") .color(TesseraPalette.CREAM_DIM) .fontSize(6f)); ``` -------------------------------- ### CSS Animation Examples Source: https://github.com/blushister/tesseraui/wiki/CSS-Animations Demonstrates applying keyframe animations to card elements. Includes an infinite 'pulse' animation, an alternating 'flash' animation, and a single-shot 'fade-in' animation. ```css /* Infinite loop — heartbeat effect */ .card-live { background: #1a2a1a; border: 1px solid #22c55e; animation: pulse 1500ms ease-in-out infinite; } /* Infinite loop, reverse on alternating cycles — flicker */ .card-flash { background: #1e1e3a; border: 1px solid #3b82f6; animation: flash 800ms ease-in-out infinite alternate; } /* Single shot — plays once on screen open */ .card-fadein { background: #1e2433; border: 1px solid #b87333; animation: fade-in 600ms ease-out 1; } ``` -------------------------------- ### Java API for @keyframes Animation Source: https://github.com/blushister/tesseraui/wiki/CSS-Animations Shows how to programmatically start a @keyframes animation on a panel using its style and a stylesheet. ```java // Start a @keyframes animation panel.cssAnimation(style.animations, sheet); ``` -------------------------------- ### CSS Transition Example Source: https://github.com/blushister/tesseraui/wiki/CSS-Animations Applies a transition to the background and border-color properties of a card element on hover. The transition occurs over 250ms with an ease-out timing function. ```css .card { background: #1e2433; border: 1px solid #b87333; transition: background 250ms ease-out, border-color 250ms ease-out; } .card:hover { background: #2a3450; border-color: #e8a24a; } ``` -------------------------------- ### CSS Multiple Selectors Source: https://github.com/blushister/tesseraui/wiki/CSS-Reference Example of applying styles to multiple selectors (h1, h2, h3) simultaneously. ```css h1, h2, h3 { font-size: 9px; } ``` -------------------------------- ### Responsive Design with Media Queries Source: https://github.com/blushister/tesseraui/wiki/CSS-Reference Adapt the layout of your web page based on the viewport width using CSS media queries. This example shows how to conditionally display a sidebar. ```css /* Default: narrow layout */ .sidebar { display: none; } /* Wide viewports (GUI Scale 1 on a large monitor) */ @media (min-width: 521px) { .sidebar { display: flex; } } ``` -------------------------------- ### CSS Tag Selector Source: https://github.com/blushister/tesseraui/wiki/CSS-Reference Example of a basic CSS tag selector targeting all 'button' elements. ```css button { } ``` -------------------------------- ### CSS Class Selector Source: https://github.com/blushister/tesseraui/wiki/CSS-Reference Example of a CSS class selector targeting elements with the class 'my-panel'. ```css .my-panel { } ``` -------------------------------- ### CSS @keyframes Definitions Source: https://github.com/blushister/tesseraui/wiki/CSS-Animations Provides examples of defining keyframe animations named 'pulse', 'flash', and 'fade-in'. These animations specify changes in background and border-color at different stages. ```css @keyframes pulse { from { background: #1a2a1a; border-color: #22c55e; } 50% { background: #14532d; border-color: #4ade80; } to { background: #1a2a1a; border-color: #22c55e; } } @keyframes flash { from { background: #1e1e3a; border-color: #3b82f6; } to { background: #1e3a7a; border-color: #60a5fa; } } @keyframes fade-in { from { background: #3a1a1a; border-color: #ef4444; } to { background: #1e2433; border-color: #b87333; } } ``` -------------------------------- ### Create and Configure TesseraInput Source: https://github.com/blushister/tesseraui/wiki/Programmatic-API Instantiate a TesseraInput with position and dimensions, then configure its placeholder, default text, maximum length, suggestions, and appearance. ```java TesseraInput input = new TesseraInput(0, 0, 120, 14); input .placeholder("Enter name…") .text("default") .maxLength(32) .suggestions(List.of("minecraft:diamond", "minecraft:emerald")) .autocomplete(true) .bgColor(0xFF2A2010) .borderColor(TesseraPalette.COPPER_LO) .textColor(TesseraPalette.CREAM) .padding(5, 3) .onChange(value -> this.name = value) .onSubmit(value -> this.save()); ``` -------------------------------- ### CSS ID Selector Source: https://github.com/blushister/tesseraui/wiki/CSS-Reference Example of a CSS ID selector targeting an element with the ID 'main-title'. ```css #main-title { } ``` -------------------------------- ### Open Basic Test Screen Source: https://github.com/blushister/tesseraui/wiki/Dev-Commands Opens the basic test screen to demonstrate labels, buttons, and basic layout. ```bash /tessera test ``` -------------------------------- ### Create and Configure TesseraLabel Source: https://github.com/blushister/tesseraui/wiki/Programmatic-API Instantiate a TesseraLabel with position and dimensions, then customize its appearance and behavior. ```java TesseraLabel label = new TesseraLabel(0, 0, width, height, "Hello world"); label .color(TesseraPalette.CREAM) .fontSize(7f) .fontWeight(700) // bold .textAlign("center") .wrap(true) // enable word-wrap .opacity(0.8f); ``` -------------------------------- ### Create Custom TesseraScreen Source: https://github.com/blushister/tesseraui/wiki/Programmatic-API Extend TesseraScreen to build custom game screens. Override init() to set up the UI and tesseraRoot() to return the root panel. ```java public class MyScreen extends TesseraScreen { private TesseraPanel root; public MyScreen() { super(Component.literal("My Screen")); } @Override protected void init() { rebuild(); } private void rebuild() { int pw = Math.min(width, 400); int ph = Math.min(height, 260); root = TesseraPanel.column((width - pw) / 2, (height - ph) / 2, pw, ph) .background(TesseraPalette.BG0) .border(1, TesseraPalette.COPPER_LO) .padding(8).gap(6); root.add(new TesseraLabel(0, 0, pw - 16, 10, "My Screen") .color(TesseraPalette.COPPER_HI).fontSize(8f)); root.layout(); } @Override protected TesseraPanel tesseraRoot() { return root; } @Override public boolean isPauseScreen() { return false; } } ``` -------------------------------- ### Create and Configure TesseraButton Source: https://github.com/blushister/tesseraui/wiki/Programmatic-API Instantiate a TesseraButton with position and dimensions, then set its label, colors, and click handler. ```java TesseraButton btn = new TesseraButton(0, 0, 80, 14); btn .label("Save") .bgColor(0xFF5C3A1E) .labelColor(TesseraPalette.COPPER_HI) .fontSize(7f) .onClick(this::onSave) .hoverBgColor(0xFF7C5A2E); ``` -------------------------------- ### Open HTML Rendering Test Screen Source: https://github.com/blushister/tesseraui/wiki/Dev-Commands Opens a test screen to explore the full HTML template pipeline. ```bash /tessera test-html ``` -------------------------------- ### Open Drag and Drop Test Screen Source: https://github.com/blushister/tesseraui/wiki/Dev-Commands Opens a test screen to demonstrate draggable widgets and drop zones. ```bash /tessera test-v18 ``` -------------------------------- ### Open Components Test Screen Source: https://github.com/blushister/tesseraui/wiki/Dev-Commands Opens a test screen to explore the component system, including `