Float
Description
The Float component is part of the Surfaces group and is designed to create absolute-positioned overlays within other containers. It is used to display UI elements that float relative to their parent container, such as buttons, labels, or custom content. Use Float when you need to position an element at one of several predefined locations (for example, top-left, center, bottom-right) within a parent container that has a relative positioning context.
Usage
To instantiate a Float component, simply call the static helper method from Tesserae.UI using the Float() operator. Pass in the child component you want to float and specify a position from the Float.Position enum. Remember to ensure that the parent container (e.g., Stack or Grid) is marked as relative by calling the .Relative() method, so that the floated component positions itself correctly.
Below is a minimal example of how to create a Float element:
Public Properties
The Float component does not expose additional public properties apart from what is provided via its constructor and the public enum for positioning.
Public Enum: Position
Defines the possible positions for the floated element. The enum values include:
- TopLeft (tss-float-topleft)
- TopMiddle (tss-float-topmiddle)
- TopRight (tss-float-topright)
- LeftCenter (tss-float-leftcenter)
- Center (tss-float-center)
- RightCenter (tss-float-rightcenter)
- BottomLeft (tss-float-bottomleft)
- BottonMiddle (tss-float-bottonmiddle)
- BottomRight (tss-float-bottomright)
API reference
public sealed class Float : IComponentA floating positioning container used to overlay a small piece of content anchored to one corner of its parent.
Constructors
Samples
Float Component Overview Sample
The sample below demonstrates how to use the Float component in a realistic scenario. A parent container is set to have a relative position, and multiple Float components are added at various positions.